It was pain to configure everything from scratch to run my Django application on Centos 5. So I thought I would save others' time by writing this blog!
Requirements:
You first need the following packages (use yum package manager for that):
gcc, gcc-c++, zlib, zlib-devel, openssl-devel, mysql, mysql-server, mysql-devel*, httpd, httpd-dev*
Install Python 2.5
Download, unzip, enter its directory, configure, make and install:
$ cd
$ wgethttp://www.python.org/ftp/python/2.5.4/Python-2.5.4.tgz
$ tar xvfz Python-2.5.4.tgz
$ cd Python-2.5.4
You need to compile it with zlib support. Therefore, you must first have zlib and zlib-devel installed:
$ ./configure --with-threads --enable-shared –with-zlib=/usr/include
$ make
$ make install
Test Python 2.5 installation:
$ python
You might need to set LD_LIBRARY_PATH environment variable
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
if you get the following error:
python: error while loading shared libraries: libpython2.5.so.1.0: cannot open shared object file: No such file or directory
Otherwise you will get:
Python 2.5.4 (r254:67916, Nov 4 2009, 15:05:38)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Install setuptools:
$ wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg#md5=64c94f3bf7a72a13ec83e0b24f2749b2
$ sh setuptools-0.6c11-py2.5.egg
Install MySQLdb
Now you need MySQLdb to connect to your MySQL server:
$ wget http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download
$ tar xvfz MySQL-python-1.2.3c1.tar.gz
$ cd MySQL-python-1.2.3c1
$ python setup.py build
$ python setup.py install
Install mod_wsgi:
It is recommended by Python and Django communities to use mod_wsgi instead of mod_python since it is more stable and faster.
$ wget http://modwsgi.googlecode.com/files/mod_wsgi-2.6.tar.gz
$ tar xvfz mod_wsgi-2.6.tar.gz
$ cd mod_wsgi-2.6
$ ./configure
$ make
$ make install
You have to make sure that the size of mod_wsgi.so equals 250k
$ ls -Al /etc/httpd/modules/mod_wsgi.so
Configure Apache to load mod_wsgi module:
Add this line to the bottom of LoadModule section in /etc/httpd/conf/httpd.conf :
LoadModule wsgi_module /usr/local/apache/modules/mod_wsgi.so
Add this line to the bottom of AddHandler section:
AddHandler wsgi-script .wsgi
Note: Apache Environment Variables are different from the OS ones, one easy way to set OS environemt variable to be passed to apache process is to append it to /etc/sysconfig/httpd file. So you can append export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" to that file.
Now you are done and ready to continue with http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/#howto-deployment-modwsgi

If you are registered you need to log in to comment, if not, please sign up.