Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 and 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 '15 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.

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

[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 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/

Output of the above command:Line2 indicates that your mod_wsgi is now using Python2.7 libraries. YAY! =>  (0x00007fffc0aa9000) => /usr/lib/ (0x00007f03a5b20000) => /lib64/ (0x00007f03a5903000) => /lib64/ (0x00007f03a56fe000) => /lib64/ (0x00007f03a54fb000) => /lib64/ (0x00007f03a5277000) => /lib64/ (0x00007f03a4ee2000)
    /lib64/ (0x00007f03a6133000)
share|improve this answer
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 '15 at 3:49

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