[Django]-How to make apache choose a particular python executable in a virtualenv for django

2👍

In your configuration, you’re actually using mod_python (which is a bit outdated, and completely different thing from mod_wsgi).

To deploy Django with mod_wsgi, it basically comes down to this, per Django docs:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
    <Files wsgi.py>
        Order allow, deny
        Allow from alll
    </Files>
</Directory>

Furthermore, you should set mod_wsgi to daemon mode, to isolate your environments:

WSGIDaemonProcess example.com python-path=/path/to/mysite.com:/path/to/venv/lib/python2.7/site-packages
WSGIProcessGroup example.com

To change Python executable for given enviroment, look into WSGIPythonExecutable directive.

👤che

2👍

Both mod_python and mod_wsgi are compiled for a specific Python version. If they are compiled for Python 2.6, you cannot force them to use a Python 2.4 installation

What you would need to do is uninstall both mod_python and mod_wsgi from your operating system and then compile mod_wsgi from source code against Python 2.4 yourself and install that.

Do note that latest mod_wsgi versions may no longer compile with such an old Python version. If the latest mod_wsgi version doesn’t compile or run properly, go back and try source code for mod_wsgi version 3.5 instead.

Leave a comment