我收到500内部服务器错误,并在日志文件中写道:
[Thu Jun 14 16:30:22 2012] [error] [client 127.0.0.1] ImportError: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings
这是我的httpd.conf:
ServerName localhost
<VirtualHost *:80>
ServerAdmin ttt@mysite.com
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite/
LogLevel warn
WSGIDaemonProcess processes=2 maximum-requests=500 threads=1
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
Alias /media /var/www/mysite/mysite/static/media/
</VirtualHost>
wsgi.py:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
答案 0 :(得分:10)
mod-wsgi文档http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango和Django部署文档https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/都涉及到这个问题,它注意到项目必须在Python路径上。您可以使用WSGIPythonPath
指令或在Django文档中的python-path
指令中设置WSGIDaemonProcess
。或者您可以将其作为mod-wsgi docs状态添加到wsgi文件中的sys.path
。