我在Ubuntu上安装了apache2并安装了Django和mod_wsgi。然后我在apache中创建了一个名为mydomain.com的虚拟主机并修改了我的hosts文件以将该地址定向到127.0.0.1,最后,我通过运行python manage.py runserver来测试我的网站,它正在运行。但是,当我浏览到http://mydomain.com时,我会收到500错误页面。看看apache错误日志这就是我得到的:
[Wed Jan 30 20:53:31 2013] [error] [client 127.0.0.1] mod_wsgi (pid=2935): Exception occurred processing WSGI script '/var/django/mydomain/mydomain.wsgi'.
[Wed Jan 30 20:53:31 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Jan 30 20:53:31 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Wed Jan 30 20:53:31 2013] [error] [client 127.0.0.1] self.load_middleware()
[Wed Jan 30 20:53:31 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
以下是mydomain.wsgi的内容
import os
import sys
sys.path.append('/var/django/mydomain')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mydomain.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我没有名为mydomain.settings的文件(我应该创建一个?),这是我第一次使用django。请指教。
答案 0 :(得分:0)
DJANGO_SETTINGS_MODULE的值应为'settings'
。