08.18.08
Installing mod_python on 64-bit redhat ES 4
I recently had to install python2.5 and mod_python on some RedHat ES4 x86_64 machines. It turned out to be a little more complicated than I anticipated. First I installed python and everything seemed OK, but later on I discovered (while trying to install some python modules) that it wasn’t compiled against zlib correctly. To add further pain, having figured out the above I tried to compile mod_python and got the following error:
/usr/bin/ld: /usr/lib/python2.4/config/libpython2.4.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/lib/python2.4/config/libpython2.4.a: could not read symbols: Bad value collect2: ld returned 1 exit status apxs:Error: Command failed with rc=65536
After some trawling the interwebs I found some answers on the python mailing list and on agile testing. Basically it comes down to how shared libraries are compiled - in certain circumstances “relocatable code” needs to be generated (presumably something to do with the larger address space on 64 bit architectures) and this isn’t done by default when you build python on a 64 bit system (the python mailing list entry above explains the rationale).
Here are the steps I used to make mod_python/python2.5 work on RedHat ES4 (x86_64):
1. install zlib1.2.3 (edit makefile with CFLAGS = "-fPIC") > ./configure --shared > make > sudo make install This puts this version of zlib in /usr/local/lib (the original is in /usr/lib) 2. install python 2.5: > ./configure --enable-shared > CFLAGS="-fPIC" CXXFLAGS="-fPIC" LDFLAGS="/usr/local/lib" make > su # make install # vi /etc/ld.so.conf.d/python2.5.conf add text '/usr/local/bin' to file and :wq (see other files in that folder for examples) # /sbin/ldconfig # exit now check if you've got 64 bit python: > python >>> import sys >>> sys.maxint 9223372036854775807 # hurray! this is a 64 bit number >>> quit() make sure you're linking against 64 bit libs: > ldd /usr/local/bin/python The listed libs should all start with /lib64 3. make sure you've got apache2 and related libs > up2date -i http http-devel 5. install mod_python 3.3.1: >./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/local/bin/python > make >sudo make install