我在 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
文件。当我将 my 设置settings.py
为 haveDEBUG = False
时,如果没有看到此自定义 500.html 页面,我将无法进入我的网站。
更奇怪的是日志文件中没有错误 - 所以我不确定在哪里查看或如何继续。由于我的自定义 500.html 文件,我知道它可以看到模板,但我不确定是什么导致了 500 内部服务器错误。
编辑:进一步配置后,我设法得到了一些错误输出(感谢@Matt Stevens),这是日志输出:
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]