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.
wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.5.1.tar.gz tar xzf virtualenv-1.5.1.tar.gz python2.4 virtualenv-1.5.1/virtualenv.py $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 is a WSGI module that connects FastCGI with Python. Make sure your FastCGI is active for the domain you are setting up.
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]/my-website.com/configuration.ini') server = WSGIServer(app) server.run()
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.
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. fcgi.py seems to be more reliable than Flup on Dreamhost.
Here is a working script, found in .
#!/home/username/bin/python from paste.deploy import loadapp from fcgi import WSGIServer app = loadapp('config:/home/username/www.yourdomain.net/yourini.ini') server = WSGIServer(app) server.run()
See Passenger WSGI