Paste passenger_wsg not working

I’m trying issues deploying my Django site but all I get is internal server errors which are worthless to debug with. I followed the advice of the following “500 Errors with Passenger WSGI Workaround.”

I followed the instructions. I put the just the “paste” directory in “myapp” directory as it said but now I get ‘An error occurred importing your’ So now I have to debug the debugger and of course i have no clue what the problem is just like my site.

[code]import sys, os
cwd = os.getcwd()
myapp_directory = cwd + '/myapp’
sys.stdout = sys.stderr
os.environ[‘DJANGO_SETTINGS_MODULE’] = "myapp.settings"
from paste.exceptions.errormiddleware import ErrorMiddleware
import django.core.handlers.wsgi
from paste.exceptions.errormiddleware import ErrorMiddleware
application = django.core.handlers.wsgi.WSGIHandler()

To cut django out of the loop, comment the above application = … line ,

and remove “test” from the below function definition.

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”

start_response(status, response_headers)
return [output]
application = ErrorMiddleware(application, debug=True)[/code]

Can someone explain how to use this. I imagine that the myapp.settings should be ‘project_name.settings’ where my settings file is. The ‘/myapp’ should the path to my django project such as ‘/home/user/’, so I got that.

Now what am I missing?


Looks like I got the site going, but I never got paste working… oh well.

In case anyone is needing help.

This worked for me. After you install django through the setup wizard (, you NEED to edit your file. You can’t just leave it as it is, otherwise your installed apps will not work under settings and you will receive internal server errors.

Under the section Migrating existing sites from FastCGI to Passenger - Migrating an existing FastCGI site you are given a clue. I ignored that part because I was NOT migrating from FastCGI, but it was actually meant for you to read even if you were not migrating from a FastCGI site.

[code]import sys, os
if sys.version < “2.4”: os.execl("/usr/bin/python2.4", “python2.4”, *sys.argv)
sys.path.insert(1, “/home/username/django/source”)
sys.path.insert(1, “/home/username/django/applications”)
sys.path.insert(1, “/home/username/django/projects”)
os.environ[‘DJANGO_SETTINGS_MODULE’] = "projectname.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


The above is important, but the actual configuration depends on your setup.

import sys, os if sys.version < "2.4": os.execl("/usr/bin/python2.4", "python2.4", *sys.argv) project_path = '/home/user/' django_path = '/home/user/Django-1.2.4/django' sys.path.append(os.getcwd()) sys.path.insert(1, project_path) sys.path.insert(1, django_path) os.environ['DJANGO_SETTINGS_MODULE'] = 'project_name.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

The above is what I did and it worked for me.