Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_wsgi and multiple installations of python

This is kind of a continuation of this question, but it has deviated so I started a new one. I'd like to use Python 2.5 instead of OS X's default 2.6. I've set this up for my terminal and whatnot, but whenever apache runs it gives me the following error output:

[Thu Jun 23 00:01:42 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Compiled for Python/2.5.4.
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Runtime using Python/2.6.1.
[Thu Jun 23 00:01:42 2011] [notice] Digest: generating secret for digest authentication ...
[Thu Jun 23 00:01:42 2011] [notice] Digest: done
[Thu Jun 23 00:01:42 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations

I've set WSGIPythonPath to match what sys.path gives me in the python shell:

WSGIPythonPath /System/Library/Frameworks/Python.framework/Versions/2.5

Still no luck. Ideas?

like image 886
Brian D Avatar asked Jun 23 '11 07:06

Brian D


People also ask

Where is Mod_wsgi so?

If installing the Apache module by hand, the file is called 'mod_wsgi.so'. The compiled Apache module can be found in the “. libs” subdirectory. The name of the file should be kept the same when copied into its appropriate location.

What is WSGIPythonHome?

WSGIPythonHome prefix|prefix:exec_prefix. Context: server config. Used to indicate to Python when it is initialised where its library files are installed.


3 Answers

You should use the following directives depending on which version of mod_wsgi you use

For mod_wsgi 1.x:

WSGIPythonExecutable /path/to/python/2.5/exe

For mod_wsgi 2.x:

WSGIPythonHome /path/to/python/2.5/exe/directory

The WSGIPythonPath is just intended to add your own libraries to the Python Path in the WSGI context.

Link to documentation: http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonExecutable

like image 125
Kaltezar Avatar answered Oct 22 '22 01:10

Kaltezar


[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Compiled for Python/2.5.4.
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Runtime using Python/2.6.1.

These two lines tell you that mod_wsgi was compiled for the wrong Python version, so you need to recompile it with the correct --with-python directive. See http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Configuring_The_Source_Code.

like image 24
xyz-123 Avatar answered Oct 22 '22 00:10

xyz-123


Here is how I resolved the similar problem on CentOS 6.7, since the default was Python 2.6, I needed to install Python 2.7 to support a Django website.

First I installed Python 2.7 with yum:

yum install python27 python27-python-devel python27-MySQL-python

the installation path of Python 2.7 is /opt/rh/python27/root/usr/bin/python

Then we need to re-compile mod_wsgi with the new paths, and here are the commands:

wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.4.21.tar.gz
tar -xzf 4.4.21.tar.gz
cd mod_wsgi-4.4.21
./configure --with-python=/opt/rh/python27/root/usr/bin/python LDFLAGS="-R/opt/rh/python27/root/usr/lib64"
make  && make install
service httpd restart
tail /var/log/httpd/error_log

The key point here is that mod_wsgi needs to locate the libpython2.7.so under /opt/rh/python27/root/usr/lib64 in my Python 2.7 installation.

Another important note in my installation was that I had to install python27-MySQL-python with yum, otherwise I got an error when installing it with pip as below:

pip install MySQL-python 
like image 21
hailong Avatar answered Oct 22 '22 00:10

hailong