我认为我的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 Internal Server错误。有什么我想念的吗?
答案 0 :(得分:0)
您需要查看发出请求时的Apache错误日志,而不是重新启动时。
问题的一个原因是sys.path不包含项目目录的父目录,因为您将DJANGO_SETTINGS_MODULE设置为必需的目录。请阅读以下内容了解此要求:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
并修复它。
除此之外,你需要确定它是Apache 500页面还是Django页面。如果它是Django,那么在Django设置文件中打开DEBUG并重新启动Apache,这样就会在浏览器中显示完整的错误。解决后关闭DEBUG。