Installing mod_python for Apache under cPanel

To begin, let's grab the latest version of mod_python. We will need to get the SVN version of mod_python as the last previous versioned release has a problem compiling on RHEL5-based systems. Since cPanel servers do not come with Subversion installed by default, we'll need to satisfy that pre-requisite first. Due to cPanel building Perl modules from source, we will be unable to install Subversion via Yum and must do so from source.

yum -y install neon neon-devel
cd /usr/src/
wget http://subversion.tigris.org/downloads/subversion-1.5.9.tar.bz2
tar xjvf subversion-1.5.9.tar.bz2
cd subversion-1.5.9 && ./configure --with-apr=/usr/local/apache/bin/ --with-apr-util=/usr/local/apache/bin/ --with-ssl --disable-mod-activation
make && make install

Now we can proceed with getting mod_python.

cd /usr/src/
svn co https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk mod_python
cd mod_python/

Now it is time to configure and build mod_python. Normally we just need to tell mod_python the location of the Apache apxs binary, but if you have additional build requirements, be sure to specify them on the configure line.

./configure --with-apxs=/usr/local/apache/bin/apxs
make && make install

make install will place the compiled DSO in the appropriate modules/ directory under Apache. All that is left to do is to tell Apache to load it as a DSO module. Edit /usr/local/apache/conf/includes/pre_main_global.conf and add the following:

# Mod_python (from SVN) support
LoadModule python_module modules/mod_python.so

Finally, restart Apache (/scripts/restartsrv_apache) and then double-check the module is loading OK:

root@server1 [~]# /usr/local/apache/bin/httpd -t -D DUMP_MODULES|grep python
Syntax OK
 python_module (shared)