From DreamHost
Jump to: navigation, search
DreamHost does not directly support any of the features described on this page and is not responsible for keeping this content updated or accurate. Use at your own risk!
There may be additional information on the talk page.

Pylons is a framework for python. In the same way the rails is a framework for ruby. See the official website. Pylons can be deployed via FastCGI on Dreamhost.


To install Pylons, you must have Python installed, as well as a few other dependencies. By default, all hosts have Python 2.4 installed, but because of permission settings, users are unable to install any new modules (as required for Pylons). Thus, you will need to setup a Virtual Python installation as described in Python#Virtualenv.

tar xzf virtualenv-1.5.1.tar.gz
python2.4 virtualenv-1.5.1/ $HOME/local

Once your Virtual Python environment is setup, you should install the following dependencies. Note that all of this should be installed in your Virtual Python environment, so you will have to explicitly call that installation of Python and not the system-wide one.

~/local/bin/easy_install pylons
~/local/bin/easy_install sqlalchemy
# Install other dependencies here...

Please note that sqlalchemy is an optional requirement, but is very commonly used with Pylons. Pylons does not explicitly list it as a dependency.


To actually serve your Pylons application, there are a few different methods. Currently, the Flup WSGI module seems to be the most stable.

Flup Method

Flup is a WSGI module that connects FastCGI with Python. Make sure your FastCGI is active for the domain you are setting up.

~/local/bin/easy_install Flup

Once Flup is installed, you will need to create a dispatch.fcgi file in your website directory: (Note you must make changes in the marked fields)

#!/home/[my user name]/local/bin/python

import sys

from paste.deploy import loadapp
from flup.server.fcgi_fork import WSGIServer

app = loadapp('config:/home/[my user name]/')
server = WSGIServer(app)

Once this is done, you must explicitly tell Apache to redirect to this file when you receive a query:

RewriteEngine On
RewriteBase /
RewriteRule ^dispatch\.fcgi/ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

Given a few minutes for the Dreamhost web daemons to catch on to the updates, the system should be ready and working!

Paster Serve Method

Paster, the Python server, can be used to run your server, commonly used via the following shell command:

paster serve --reload dev.ini

There are issues with this: (1) you cannot bind on any port below 1024, because they are all taken by Apache (i.e. you can't serve on the regular HTTP port 80) and (2) Dreamhost commonly kills long-serving daemon processes. As part of your Terms of Service, Dreamhost disallows this and is in their right to kill your process.

FastCGI Method

Note that this section contains dead links - you are on your own!

The FastCGI installations apply, except that you don't need to limit the FastCGI script to dispatch.fcgi, other names with .fcgi suffix seem to work too. seems to be more reliable than Flup on Dreamhost.


Here is a working script, found in [1].


from paste.deploy import loadapp
from fcgi import WSGIServer

app = loadapp('config:/home/username/')
server = WSGIServer(app)

Passenger WSGI

See Passenger WSGI