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 https://github.com/GrahamDumpleton/mod_wsgi/releases/tag/4.5.6 $ 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/mod_wsgi.so into server: libpython3.5.m.so.1.0: 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/mod_wsgi.so linux-vdso.so.1 => (0x00007fff08704000) libpython3.5m.so.1.0 => not found libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f96abbfc000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f96ab9f8000) libutil.so.1 => /lib64/libutil.so.1 (0x00007f96ab7f5000) librt.so.1 => /lib64/librt.so.1 (0x00007f96ab5ec000) libm.so.6 => /lib64/libm.so.6 (0x00007f96ab368000) libc.so.6 => /lib64/libc.so.6 (0x00007f96aafd4000) /lib64/ld-linux-x86-64.so.2 (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/mod_wsgi.so linux-vdso.so.1 => (0x00007fffff9f7000) libpython3.5m.so.1.0 => /opt/anaconda3/lib/libpython3.5m.so.1.0 (0x00007f6b55b00000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6b558d7000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f6b556d3000) libutil.so.1 => /lib64/libutil.so.1 (0x00007f6b554d0000) librt.so.1 => /lib64/librt.so.1 (0x00007f6b552c7000) libm.so.6 => /lib64/libm.so.6 (0x00007f6b55043000) libc.so.6 => /lib64/libc.so.6 (0x00007f6b54caf000) /lib64/ld-linux-x86-64.so.2 (0x00007f6b56228000)
So that’s that.