Django Installation
1.1 Install Django
Django isn’t installed by default in PLANET ARGON, so you will have to set up your own personal copy of django. Since you will have to install other software too, let’s make a directory in which we will drop all our software:
cd $HOME
mkdir src
cd src
I use django fron svn, so the command is:
svn co http://code.djangoproject.com/svn/django/trunk/ django_src
This will create a directory called django_src with all the django source code
Now you’ll need to set your PATH and PYTHONPATH environment variables to know a couple of things: your PATH will need to include the directory django-admin.py is in so you can use it on the command line, and your PYTHONPATH will need to include the locations of Django and of your project, so you’ll be able to import the appropriate modules. To do this, you’ll just need to add a couple of lines to your .bash_profile file. These files live in your home directory.
export PATH=$PATH:$HOME/src/django_src/django/bin
export PYTHONPATH=$PYTHONPATH:$HOME/src/django_src:$HOME/src
Once you’ve done this, either log out and back in again (to force your environment variables to update), or type the command bash .bash_profile
1.2 Test your Django installation
Fire up the Python interpreter by typing the command python, and try this:
from django.core.handlers.wsgi import WSGIHandler
Or import pretty much any other Django component of your choice. If no errors appear, then Django is successfully installed and will work for your account. If you do see errors, log out (to get out of the Python interpreter and back to the command line, press Ctrl+D) and back in again to be sure your environment variables are updated, then try again. If it still doesn’t work, go back to step 1.4 and double-check that you added the correct lines to your .bash_profile
Also be sure to check that django-admin.py is now in your PATH. To test this, begin typing the command, but don’t type the whole thing and hit Enter; instead, type only part of it (say, just ‘django’) and hit Tab; after a short pause, the rest of the command should automatically appear. If it does, then django-admin.py is in your PATH. If not, log out and back in again and try again. If it still doesn’t work, go back to step 1.4 and double-check that you added the correct items to your .shrc and .profile files.
1.3 Install flup
To use Django with FastCGI, we’ll be using a Python package called flup which provides modules for setting up a FastCGI server. You’ll need your own local copy of it, so go into the ‘src’ directory again and type this command to download flup:
wget http://www.saddi.com/software/flup/dist/flup-r1826.tar.gz
Then unpack it by typing tar zxvf flup-r1826.tar.gz. This will unpack flup into a directory called flup-r1826, but we really just want it to be called flup (so we can do import flup in Python). There is a directory by this name inside flup-r1826, and it contains everything we need, so we’ll just move it up one level and get rid of everything else. Go into the flup-r1826 directory (cd flup-r1826) and type these commands:
mv flup ../
cd ../
rm flup-1826*
1.4 Test your flup installation
Fire up the Python interpreter again, and type this:
from flup.server.fcgi_fork import WSGIServer
If you don’t see any errors, flup is installed and available. This will work without any additional edits to your .shrc or .profile files because you added your local directory to your PYTHONPATH in step 1.4; any Python module in a subdirectory of local can then be imported by its name without any further configuration. If it doesn’t work, double-check that the lines you added to your .shrc and .profile files are correct (see step 1.4).
Now you’ve now got all the necessary prerequisites for using Django and FastCGI installed, so the next step is to upload and install your Django project.
1.5 Lighttpd and FCGI
TODO
Credits Some material is borrowed from http://manuals.textdrive.com/read/book/15