Desinerd : Dipankar's Blog

Python, Passenger phusion and dreamhost

Published: in @Work, , , , by .

Well, had to setup some stuff on dreamhost. Turns out that they are fairly bad on django hosting. Here is a working passenger_wsgi.py that is possibly much better than the default. Please not that you must have paste [http://pythonpaste.org/]  installed for this to work correctly.

This has python2.7 locally installed in your account, with all the libraries locally. Dreamhost is quite painful, as the documentation is incomplete clearly!

import sys, os
if sys.version < “2.7”: os.execl(“/path/to/python”, “/path/to/ python”, *sys.argv)
sys.stdout = sys.stderr
sys.path.insert(0,”/path/to/Django-1.3.1″)
sys.path.insert(0,”/path/to/project”)
sys.path.append(“/path/to/project root directory”)
os.environ[“DJANGO_SETTINGS_MODULE”] = “project.settings”
from paste.exceptions.errormiddleware import ErrorMiddleware
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
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)))]
start_response(status, response_headers)
return [output]
application = ErrorMiddleware(application, debug=True)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *