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 that is possibly much better than the default. Please not that you must have paste []  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.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)


Leave a Reply

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