Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

I am trying to configure mod_wsgi to use Python 2.7.

I downloaded and unpacked the source and ran

./configure --with-python=/usr/local/bin/python2.7

After this mod_wsgi.so-2.4 and mod_wsgi.so-2.5 appeared in /usr/lib/apache2/modules.

I restarted the server but this reports "internal server error". Error logs show that on start-up the server is reporting usage of Python 2.5.2 -- the same version as previously.

How do I get Apache to run Python 2.7? How do I get mod_wsgi configured properly to run with Python 2.7?

share|improve this question

marked as duplicate by masegaloeh, Andrew Schulman, Katherine Villyard, MadHatter, Jenny D May 27 at 10:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

You have a system package for mod_wsgi installed which is conflicting. If you don't need them, uninstall the system package for mod_wsgi.

Also make sure you read:

as you may need to set LD_RUN_PATH to /usr/local/lib when building mod_wsgi so that it knows where to find the Python library at runtime, if /usr/local/lib is not listed in system ld.cache.

You also may need to set:

WSGIPythonHome /usr/local

in Apache configuration so mod_wsgi knows where Python 2.7 is since not in system location.

Also make sure Python 2.7 was installed with a shared library.

share|improve this answer
    
Thx. I did a workaround for the immediate problem but I need to get this under control and will circle back to it soon –  chernevik Dec 3 '12 at 22:51

This is how you can configure mod_wsgi to use Python2.7

I happened to face this same issue. And I was looking at the option on uninstalling mod_wsgi and re-installing it with appropriate configs.

Reading one of the articles I realized there was no need to un-install my current mod_wsgi and I could just go ahead and re-install mod_wsgi3.4 (earlier i had v3.2) with the settings to use Python2.7 (seems like the installation process re-writes everything without any errors/conflicts).

Since I already had Python2.7 installed.

I reinstalled mod_wsgi-3.4 (without performing any un-installations)

[root@server ~]# cd ~

[root@server ~]# wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz

[root@server ~]# tar xvf mod_wsgi-3.4.tar.gz

[root@server ~]# cd mod_wsgi-3.4

Configured mod_wsgi with the installed python2.7

[root@server ~]#./configure --with-python=/usr/local/bin/python2.7

[root@server ~]# make

[root@server ~]# make install

The below two commands are very important. Replace /usr/local/lib with the folder where you have installed libpython2.7.so.1.0 if it is not in /usr/local/lib.

[root@server ~]# LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/python

[root@server ~]# ldconfig

Restart Apache Server

[root@server ~]# service httpd restart

[root@server ~]# ldd /etc/httpd/modules/mod_wsgi.so

Output of the above command:Line2 indicates that your mod_wsgi is now using Python2.7 libraries. YAY!

    linux-vdso.so.1 =>  (0x00007fffc0aa9000)
    libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007f03a5b20000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f03a5903000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f03a56fe000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f03a54fb000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f03a5277000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f03a4ee2000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f03a6133000)
share|improve this answer
1  
Please note that tarball-type installation/reinstallation/repair usually conflicts with package management (on RedHat and Debian based systems, for instance). In other words, if you haven't built your Linux from scratch, tarballing isn't great. –  Deer Hunter May 26 at 3:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.