Fork me on GitHub

Installing Django on Centos 5

In preparing to upgrade this server to Centos 5.x, I did a test install of the Centos "Server" configuration using VirtualBox. The "Server" configuration comes with Apache 2.x, Python 2.4, and mod_python pre-loaded.

Installing Django

Here are the commands needed to install the latest version of Django:

$ yum install subversion
$ cd /var/www
$ mkdir django-src
$ cd django-src
$ svn co http://code.djangoproject.com/svn/django/trunk/
$ cd trunk
$ python setup.py install

Installing and Starting MySQL Server

Here are commands needed to install and start MySQL:

$ yum install mysql-server
$ /etc/rc.d/init.d/mysqld start

Installing Python MySQL Support

This is the trickiest part. Python talks to MySQL using software called MySQLdb. The version available in Centos via Yum is 1.2.1-1 and isn't compatible with the most recent Django codebase. Because of this you must download and compile MySQLdb.

Before compiling MySQLdb, enter the command below to make sure you have the necessary tools:

$ yum install python-devel mysql-devel gcc

Next, download the source tarball from SourceForge then follow these steps:

$ mv <name of MySQLdb tarball> ~
$ cd ~
$ tar zxvf <filename of MySQLdb tarball>
$ cd <name of resulting directory>
$ python setup.py build
$ python setup.py install

When these steps are completed you should be good to go.