Python, Passenger phusion and dreamhost

January 22nd, 2012 § 0 comments

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)

Tagged , , ,

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">