I've set up a Django project hosted on Dreamhost using Passenger WSGI according to their wiki instructions and ran into the problem of internal errors popping up and crashing mod_wsgi.
I installed Python Paste by following their instructions to get comprehensive logs displayed in the webpage, but it doesn't work. IE: Anytime I have internal errors, I still get django's "internal error" page without any other information in the browser.
When I tested paste's install by removing "test" in front of the "def testapplication", that worked fine. But whenever I have an internal error, I still don't get paste's output with complete error information. Instead I get the same cryptic internal error page with no information.
According to their wiki, my configuration is correct:
My passenger_wsgi.py file:
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)
My web server error log (error.log) is empty, and my access log (access.log) is full of messages like the following (latest line - edited with bogus links). There's logging happening somewhere, because the access.log is logging something, but the errors aren't showing up anywhere - except in that cryptic "internal error" page.
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"
The Django project is running well on my dev environment, but there's some kind of server problem happening when it's running off Passenger WSGI on the server - I installed Paste to try and debug these errors. When my install runs into any kind of non-Django error, I get that cryptic "internal error" message.