How to setup Django on Slicehost

So you’re setting a new host. This should make it easier to setup on CentOS 5.5. This list isn’t complete since you will need to setup django but this should at least get the system the basic packages to start moving.

  • vim-enhanced
  • python mod_python
  • httpd
  • mysql.x86_64
  • mysql-server.x86_64
  • subversion.x86_64
  • python
  • screen
  • mlocate
  • python-devel.x86_64
  • mysql-devel.x86_64
  • gcc
  • python-setuptools.noarch

Download  Open Source packages


tar -zxvf django.1.2.tar.gz
python install

Once installed, this should make available from command line. Installation of django typically goes into /usr/lib/python2.x/site-packages/django


You will need to have the mysql-python connector to allow django/python to connect properly to the database. This of course will require MySQL server and client is installed and running on the box.

tar -xvzf MySQL-python-1.2.3c1.tar.gz
python build
python install

Apache Configurations

There are several small steps that need to be happen before django will work properly.

Django admin files have to be made available to the public.

ln -s /var/www/html/media  /usr/lib/python2.4/site-packages/django/contrib/admin/media

Setup an eggs directory for apache

mkdir /var/www/eggs

Add the following to the httpd.conf file

<Location “/”>
SetHandler python-program
PythonPath “[‘/usr/local’, ‘/var/www’] + sys.path”
PythonHandler django.core.handlers.modpython
SetEnv PYTHON_EGG_CACHE /var/www/eggs
PythonDebug On
ErrorDocument 404 /errors/404.html

<Location “/media”>
SetHandler None

At this point, you have about 80% of the work done to get django up and running from a blank host. All that needs to happen from here is to configure your and create your django application. Good luck and hope this helps!