Compiling and Installing mod_wsgi 4.5.6 on RHEL/CentOS 6

Just a quick note in addition to the troubleshooting post I provided;

When compiling mod_wsgi from source (which is Graham Dumpleton’s serious recommendation), you may choose to compile the module with a different version of Python than that which is included with the RHEL/CentOS operating system.  The reason you would do this is that mod_wsgi needs to be compiled with the version of Python that is used by the program you intend to support with the module (e.g. you cannot run a Python 3.5 program with a WSGI module compiled with Python 2.7).  This is especially common with RHEL/CentOS since Python 2.7 is what the OS is based on, and we’re all the way up to Python 3.5 now, with a lot of superiority over the old major version 2.

So, if you have to do that, you’re going to need to perform the compilation by directing the system to the Python library to be used in compiling the module.  If that Python library is not in the standard LD_RUN_PATH (likely if it’s not in /usr, but /opt, as in my case), you’ll need to do this:

 $ wget
 $ tar xf 4.5.6.tar && cd 4.5.6
 $ ./configure --with-python=/opt/anaconda3/bin/python3.5
 $ LD_RUN_PATH=/opt/anaconda3/lib make
 $ sudo make install

You can tell you need to do that if you find the WSGI module refuses to load, providing the following error message in /var/log/httpd/error_log:

httpd: Syntax error on line 222 of /etc/httpd/conf/httpd.conf: 
Syntax error on line 1 of /etc/httpd/conf.d/wsgi.conf: Cannot load /etc/httpd/modules/ into server: cannot open shared object file: No such file or directory

And then you investigate the module’s linked libraries like so:

# ldd /etc/httpd/modules/ =>  (0x00007fff08704000) => not found => /lib64/ (0x00007f96abbfc000) => /lib64/ (0x00007f96ab9f8000) => /lib64/ (0x00007f96ab7f5000) => /lib64/ (0x00007f96ab5ec000) => /lib64/ (0x00007f96ab368000) => /lib64/ (0x00007f96aafd4000)
        /lib64/ (0x00007f96ac05d000)

That “not found” bit is a problem; what you will see after you compile with the LD_RUN_PATH specification above is this:

# ldd /etc/httpd/modules/ =>  (0x00007fffff9f7000) => /opt/anaconda3/lib/ (0x00007f6b55b00000) => /lib64/ (0x00007f6b558d7000) => /lib64/ (0x00007f6b556d3000) => /lib64/ (0x00007f6b554d0000) => /lib64/ (0x00007f6b552c7000) => /lib64/ (0x00007f6b55043000) => /lib64/ (0x00007f6b54caf000)
        /lib64/ (0x00007f6b56228000)

So that’s that.

This entry was posted in Information Technology and tagged , , , , . Bookmark the permalink.

1 Response to Compiling and Installing mod_wsgi 4.5.6 on RHEL/CentOS 6

  1. Vidya says:

    wget file is not a .tar file

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s