我在CentOS上部署了一個Django應用程序。這裏是我的httpd.conf文件看起來是這樣的:Django Apache mod_wsgi 500
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', '[email protected]'),
('David', '[email protected]'),
)
SEND_BROKEN_LINK_EMAILS = True
DEFAULT_FROM_EMAIL = '[email protected]'
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]
當您將debug設置爲true時,一切功能是否正常? – 2013-02-26 19:16:05
是的 - 我可以正常訪問所有內容(我的所有URL都可以工作,一切都可以)。 – lightningmanic 2013-02-26 19:20:50
你的template_dirs元組是什麼樣的? – 2013-02-26 21:32:12