我已经部署在CentOS Django应用程序。 这里是我的httpd.conf文件的样子:
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:80>
WSGIDaemonProcess safe python-path=/usr/lib/python2.6/site-packages
WSGIProcessGroup safe
WSGIScriptAlias / /opt/safe/safe/wsgi.py
<Directory /opt/safe/safe/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
编辑:这是我的TEMPLATE_DIRS
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/opt/safe/static/templates",
"/var/www/html/static/templates",
)
编辑:这是我的联系/电子邮件设置:
ADMINS = (
# ('Your Name', 'your_email@example.com'),
('David', 'david@localhost'),
)
SEND_BROKEN_LINK_EMAILS = True
DEFAULT_FROM_EMAIL = 'david@localhost'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
在我的模板目录中,我定义了自定义500.html
文件。 当我把我的settings.py
有DEBUG = False
,我不能在任何地方得到我的网站上没有看到这一习俗500.html页。
什么是更奇怪的是,有在日志文件中没有错误的事实 - 所以我不确定在哪里看或如何进行。 我知道它可以看到,因为我的自定义500.html文件的模板,但我不知道是什么原因造成的500内部服务器错误。
编辑:进一步的配置后,我设法得到了一些错误输出(感谢@马特·史蒂文斯),这里是日志的输出:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 89, in get_response
response = middleware_method(request)
File "/usr/lib/python2.6/site-packages/django/middleware/common.py", line 55, in process_request
host = request.get_host()
File "/usr/lib/python2.6/site-packages/django/http/__init__.py", line 223, in get_host
"Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): %s" % host)
SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): [my ip address]