簡體   English   中英

Django EC2 mod_wsgi 配置與 Apache 不工作

[英]Django EC2 mod_wsgi configuration with Apache not working

我認為我的 apache2 服務器即將設置完畢,但它仍然返回 500 錯誤。 這是我的.wsgi文件:

import os, sys

#path to directory of the .wsgi file ('apache/')
wsgi_dir = os.path.abspath(os.path.dirname(__file__))

#path to project root directory (parent of 'apache/')
project_dir = os.path.dirname(wsgi_dir)

sys.path.append(project_dir)
project_settings = os.path.join(project_dir, 'settings')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ecomstore.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

這是我的virtualhost文件:

NameVirtualHost *:80
 <VirtualHost *:80>
      ServerAdmin admin@site.com
      ServerName www.site.com
      ServerAlias site.com

      Alias /static /home/ecomstore/static

      DocumentRoot /home/ecomstore
      WSGIScriptAlias / /home/ecomstore/apache/ecomstore.wsgi

      ErrorLog /var/log/apache2/error.log

      LogLevel warn

      CustomLog /var/log/apache2/access.log combined

 </VirtualHost>

這是我的服務器重啟:

sudo /etc/init.d/apache2 restart
 * Restarting web server apache2
[Sun Apr 08 02:47:31 2012] [warn] module wsgi_module is already loaded, skipping
 ... waiting ..........[Sun Apr 08 02:47:42 2012] [warn] module wsgi_module is already loaded, skipping
   ...done.

然而,即使我在重新啟動時沒有收到 mod-wsgi 配置的錯誤,我仍然收到前面提到的 500 內部服務器錯誤。 有什么我想念的嗎?

您需要查看發出請求時的 Apache 錯誤日志,而不是重新啟動時的錯誤日志。

問題的來源之一是 sys.path 不包括項目目錄的父目錄,這是必需的,因為您將 DJANGO_SETTINGS_MODULE 設置為。 Go 閱讀此要求:

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

並修復它。

除此之外,您需要確定它是 Apache 500 頁面還是 Django 頁面。 如果它是 Django,那么在 Django 設置文件中打開 DEBUG 並重新啟動 Apache,這樣您就會在瀏覽器中看到一個完整的錯誤。 解決后關閉 DEBUG。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM