我已经使用Passenger WSGI according to their wiki instructions设置了Dreamhost上托管的Django项目,并遇到内部错误弹出和崩溃mod_wsgi的问题。python粘贴不显示错误跟踪
我安装了Python Paste by following their instructions以获取网页中显示的综合日志,但它不起作用。 IE:任何时候我有内部错误,我仍然会在浏览器中看到django的“内部错误”页面而没有任何其他信息。
当我通过在“def testapplication”前面删除“test”来测试粘贴的安装时,它工作正常。但是每当我发生内部错误时,我仍然无法获得粘贴输出的完整错误信息。相反,我得到了没有任何信息的同样神秘的内部错误页面。
根据自己的wiki,我的配置是正确的:
我passenger_wsgi.py文件:
import os, sys
import django.core.handlers.wsgi
INTERP = os.path.join(os.environ['HOME'], 'env', 'bin', 'python')
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
os.environ['DJANGO_SETTINGS_MODULE'] = "abc.settings"
sys.path.append(os.getcwd())
sys.path.append(os.path.join(os.getcwd(), 'abc'))
log = file('/home/abcadmin/passengerwsgi.log', 'a')
print >>log, "Running %s" % (sys.executable)
application = django.core.handlers.wsgi.WSGIHandler()
from paste.exceptions.errormiddleware import ErrorMiddleware
sys.stdout = sys.stderr
# remove the "test" below to test paste
def testapplication(environ, start_response):
status = '200 OK'
output = 'Hello World! Running Python version ' + sys.version + '\n\n'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
# to test paste's error catching prowess, uncomment the following line
# while this function is the "application"
raise("error")
start_response(status, response_headers)
return [output]
application = ErrorMiddleware(application, debug=True)
我的web服务器错误日志(error.log中)是空的,我的访问日志(访问.log)中充满了以下消息(最新的一行 - 用伪链接编辑)。记录发生在某处,因为access.log正在记录某些内容,但这些错误不会显示在任何地方 - 除了那个神秘的“内部错误”页面。
46.246.117.3 - - [21/Feb/2012:00:27:04 -0800] "GET /admin/ HTTP/1.1" 200 2326 "http://abc.acme.com/admin/userProfile/profile/16/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.2) Gecko/20100101 Firefox/10.0.2"
Django的项目是在我的开发环境运行良好,但有某种服务器的问题,当它运行在服务器上关闭客运WSGI发生的一切 - 我安装粘贴尝试和调试这些错误。当我的安装遇到任何类型的非Django错误时,我会得到那个神秘的“内部错误”消息。
你的**网络服务器错误日志**说什么? – 2012-02-21 08:51:39
刚刚用一个答案编辑了问题 - 参见上面的 – serpah 2012-02-21 08:57:53