Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python.
This involves recompiling Python with the correct flags, then recompiling mod_wsgi using the newly compiled Python. Below shows the steps,
Check Version
First of all check what version of Python mod_wsgi was compiled with.
[[email protected]]# ldd /usr/lib64/httpd/modules/mod_wsgi.so
libpython2.4.so.1.0 => /usr/lib64/libpython2.4.so.1.0 (0x00002b3149c4e000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b3149f82000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002b314a19d000)
libutil.so.1 => /lib64/libutil.so.1 (0x00002b314a3a2000)
libm.so.6 => /lib64/libm.so.6 (0x00002b314a5a5000)
libc.so.6 => /lib64/libc.so.6 (0x00002b314a828000)
/lib64/ld-linux-x86-64.so.2 (0x000000364b200000)
Compile Python
Next, compile Python. The option to build a shared library is also used to prevent future issues (details can be found here).
yum groupinstall “Development tools”
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
cd ~
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar xvf Python-2.7.5.tgz
cd Python-2.7.5
./configure –enable-shared –with-threads
make
make install
Once you have complete these steps you may get the error,
There are 2 ways to fix this. You can :
1. run ‘echo export LD_LIBRARY_PATH=/usr/local/lib >> /etc/profile’ or
2. configure the following softlinks
ln -s /usr/local/lib/libpython2.7.so.1.0 /usr/lib/
ln -s /usr/local/lib/libpython2.7.so /usr/
Compile WSGI
Finally we compile wsgi,
cd ~
wget
tar xvf mod_wsgi-3.4.tar.gz
cd mod_wsgi-3.4
./configure –with-python=/usr/local/bin/python2.7
make
make install
References
http://stackoverflow.com/questions/7880454/python-executable-not-finding-libpython-shared-library
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018
- Cisco – What is BGP ORF (Outbound Route Filtering)? - March 5, 2018
Want to become a programming expert?
Here is our hand-picked selection of the best courses you can find online:
Python Zero to Hero course
Python Pro Bootcamp
Bash Scripting and Shell Programming course
Automate with Shell Scripting course
The Complete Web Development Bootcamp course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial