0

I've compiled python 2.7.8 with:

mkdir -p /usr/local/python2p7/lib
./configure --prefix=/usr/local/python2p7 --with-threads --enable-shared LDFLAGS="-Wl,-rpath /usr/local/python2p7/lib"
make
make install altinstall

I'm using the LDFLAGS so this install doesn't conflict with CentOS 7 built in python 2.7.5.

I compile modwsgi 4.2.6:

./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/python2p7/bin/python LDFLAGS="-L/usr/local/python2p7/lib"
 make
 make install

If I run:

ldd /usr/local/apache/modules/mod_wsgi.so

I get

...
libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007f648d9a0000)
...

How do I get mod wsgi to use /usr/local/python2p7/lib/libpython2.7.so.1.0?

*******Solution*******

With the help of Graham Dumpleton:

To compile modwsgi:

export LD_RUN_PATH=/usr/local/python2p7/lib
./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/python2p7/bin/python
make
make install
unset LD_RUN_PATH

In apache config set

WSGIPythonHome /usr/local/python2p7

I initial set it to "/usr/local/python2p7/bin" and got the "ImportError: No module named site" error.

brian
  • 113
  • 1
  • 1
  • 6

1 Answers1

0

This is covered in the mod_wsgi documentation. See:

You will need to set LD_RUN_PATH environment variable to appropriate library directory when compiling mod_wsgi to ensure it uses the correct Python shared library.

Also read:

in case at run time it still picks up wrong run time files. In that case you need to also set WSGIPythonHome.

As far as compiling from source code, the other reason is that CentOS still ships an old mod_wsgi.

You might even consider using the pip installable mod_wsgi in place of doing what you are doing now. See:

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19
  • setting the env var LD_RUN_PATH fixed the problem. I thought setting the configure flag LDFLAGS would do the same thing. – brian Jul 22 '14 at 18:13
  • LDFLAGS is setting options to be used at compile time linking to find it and know it exists. LD_RUN_PATH is embedding directories to be searched at run time for the shared library. – Graham Dumpleton Jul 23 '14 at 01:19