You are here

Installation of Python and Web2py on Dreamhost

Submitted by devblog on Thu, 11/02/2010 - 13:38

These wiki pages pretty much cover the process.

Compiling Python on a Dreamhost

Web2py itself

After downloading the Web2py package and installing it, the web directory is configured for serving up the cgi pages.

First the dispatch.fcgi

#!/home/user/packages/bin/python
import sys
from flup.server.fcgi_fork import WSGIServer
import gluon.main
application=gluon.main.wsgibase
## or
# application=gluon.main.wsgibase_with_logging
WSGIServer(application).run()

and the .htaccess settings.

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

In installing the first time I used the python command before my own installation was finished, executed the native Dreamhost version which was Python 2.4. That messed up my own Flup installation which used easy_install Flup command.

This I worked round by seeing how a Flup was installed manually in this forum page.

wget http://www.saddi.com/software/flup/dist/flup-1.0.tar.gz
tar xvzf flup-1.0.tar.gz
cd flup-1.0 and chmod +x *
python2.5 ez_setup.py -U setuptools
python2.5 setup.py install

Install Script (untested)

#need to build python, as Dreamhost does not have 
#python 2.5 installed, wiki notes indicates 2.6 works
#with some caveats
 
# Python itself
mkdir -p ~/tasks/buildpython
cd ~tasks/buildpython
wget http://python.org/ftp/python/VERSION/Python-2.5.x.tgz
tar -xzvf Python-2.5.x.tgz
cd Python-VERSION
~/.configure --prefix=$HOME/packages
make
make install
 
#setup tools for Python
cd ${HOME}/packages
wget http://peak.telecommunity.com/dist/ez_setup.py
${HOME}/packages/bin/python ez_setup.py
 
#install Flup
cd ~tasks/buildpython
easy_install Flup
#change to web root to install web2py proper
cd ${HOME}/domain.com
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cd web2py
 
#create dispatch.fcgi and .htaccess here
 
cat > dispatch.fcgi <<CODE-HERE
#!python2.5
import sys
from flup.server.fcgi_fork import WSGIServer
import gluon.main
application=gluon.main.wsgibase
## or
# application=gluon.main.wsgibase_with_logging
WSGIServer(application).run()
CODE-HERE
 
chmod u+x dispatch.fcgi
 
cat > .htaccess <<CODE-HERE
RewriteEngine On
RewriteBase /
RewriteRule ^dispatch\.fcgi/ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
CODE-HERE
 
 
python web2py.py

Vertical Tabs

Add new comment