Official ObjectGraph Blog

Friday, January 05, 2007

Recompilining Apache with mod python
After a long struggle with getting Django working with Apache, I came to the conclusion the Apache that came with Cent OS does not work well with the newly compiled Python 2.4.4, It seems to fall back on the older version of python (2.3.4) which is already in the system.

So i decided to compile Apache from source and it works beautifully.

And apache is very clean, when you compile from scratch. I was able to compile the latest version (2.2) and recompile mod python.

Removed all httpd related packages from CentOS
php-5.1.6-1.2.1.centos 
php-mysql-5.1.6-1.2.1.centos 
php-pear-1.4.9-1.2.centos 
php-pdo-5.1.6-1.2.1.centos
httpd-suexec-2.0.52-28.ent.centos4 
httpd-2.0.52-28.ent.centos4

Then got the latest version of apache.

#wget http://apache.mirrormax.net/httpd/httpd-2.2.3.tar.gz 
#tar xvfz httpd-2.2.3.tar.gz
#cd httpd-2.2.3
#./configure
#make
#make install

this time mod python was again complaining. You will have to compile with the apxs installed by the new apache 2.2.3

#./configure --with-apxs=/usr/local/apache2/bin/apxs

So what did i learn from this exercise.

Always recompile everything unless you want to stick to versions of python that came with the distro.

Labels: , ,


posted by gavi at 10:28 AM | 0 comments |

Thursday, January 04, 2007

Installing mod_python on Apache
Now for todays post. Installing mod python and apache.

#wget http://apache.mirror99.com/httpd/modpython/mod_python-3.2.10.tgz
#tar xvfz mod_python-3.2.10.tgz
#cd mod_python-3.2.10
#ls -al
#./configure
I get an error at this stage saying apxs or apxs2 not found. So basically its looking for httpd-devel packages. Just did

#yum install httpd-devel
and I was able to build it successfully.

#./configure
#make
#make install
it put mod_python.so in

/usr/lib/httpd/modules
The next step would be to configure Django with Apache.

Labels: , ,


posted by gavi at 11:33 AM | 0 comments |

Wednesday, January 03, 2007

Installing Python 2.4.4 on Cent OS 4.4 (Final)
We at ObjectGraph are moving to a dedicated hosting solution. The server is hosted in NY. It has Cent OS 4.4 (Based on RHEL 4). It comes installed with Python 2.3.4. A lot of packages (like yum) depend on this version of python in the system. So when i found out that some of the syntax like '@staticfunction' we were using to develop in django is not compatible with python 2.3.4, I was distraught. I decided i need to upgrade python. Here is a simple test program that fails in the older version of Python.

class Test:
        def __init__(self):
                print "Hello World!"
        def sum(self,a,b):
                return a+b

        @staticmethod
        def sum1(a,b):
                return a+b
t=Test()
print t.sum(10,10)
print t.sum1(10,10)

After a lot of struggle to find a binary package of Python 2.4.4 for Cent OS, I gave up and compiled python from source. It was pretty straightforward and i am happy with the results. This is what i did.
#wget http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tgz
#tar xvfz *.tgz
#cd Python-2.4.4
#./configure
#make
#make install
Just run python to see if it is the version 2.4.4 Now python is cleanly installed. The site-packages folder under /usr/local/lib/python2.4 are empty. So get the latest version of django and install it

#svn co http://code.djangoproject.com/svn/django/trunk/ django
#cd django
#python setup.py install
Similary you can install MySQLdb and other libraries you want on python. Now the next steps for us is to get django running on Apache using mod_python

Labels: , , ,


posted by gavi at 10:02 PM | 2 comments |