Dec 22

Djumpstart on webfaction

5:30 in the morning and I just finished a django project in under 3 hours from scratch*, all the way to deployment on webfaction (referal link). I've been using agilezen for a week now and I'm thrilled. I wanted to document from beginning to end how to deploy on webfaction, and here goes the first part.

Preface: Webfaction rocks!

Webfaction combines the power of a virtual hosting solution and the convenience of a traditional hosted solution. You have all the tools you need, and it is easy to install your own if there is something missing, but at the same time they take care of keeping the system secure and up to date. They have really competitive prices and plans for all the goodies they offer, and their support rocks. But I have no need to ramble about how good they are, the web is already full of good reviews, and surprisingly few negative ones.

Chapter 1: Setting up your python environment and installing deployment tools.

Webfaction has excellent python support, with versions 2.4, 2.5, 2.6, 3.0, 3.1 installed by default, and if you need anything else it is easy to install it yourself.

We will start by setting python 2.6 as system default, and install the tools we will need to deploy our app: virtualenv, virtualenvwrapper, pip, subversion, git and mercurial.

Python

Set python 2.6 as system default, and install virtualenv, virtualenvwrapper, pip and mercurial:

a) Create python 2.6 lib directory:

mkdir /home/{{accountname}}/lib/python2.6

b) add the following lines to your bashrc file:

alias python=python2.6 export LD_LIBRARY_PATH=$HOME/lib

c) install pip, making sure you use easy_install 2.6, and install virtualenv.

$ easy_install-2.6 pip $ pip install virtualenv virtualenvwrapper mercurial $ mkdir $HOME/virtualenvs

d) add the following lines to your bashrc file:

VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.6 export WORKON_HOME=$HOME/virtualenvs source /home/{{accountname}}/bin/virtualenvwrapper.sh

Version Control Applications

Subversion is installed by default, and to install git you can either install it from webfaction’s app installer or manually:

$ wget http://www.kernel.org/pub/software/scm/git/git-1.7.x.x.tar.gz $ tar zxf git-1.7.x.x.tar.gz $ cd git-1.7.x.x $ ./configure --prefix=$HOME $ make $ make install

Installing mercurial using pip is easy too: pip install mercurial

So now you have everything you need to start deploying your django apps on webfaction. In the next part I'll show how to setup django using two setup methods: the traditional mod_wsgi+apache way, and the cutting edge gunicorn+nginx way :) Time to go to bed.

Resources: http://docs.webfaction.com/software/python.html http://docs.webfaction.com/software/git.html