Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto configure Apache WSGI for multiple separate Django instances?

I have an apache instance where I have the following

WSGIPythonPath /production/somelocation/django12/lib/python2.4/site-packages/
<VirtualHost 192.168.1.1:443>
        WSGIScriptAlias / /opt/project.wsgi
        .....

My Django 1.5 app apache config looks like,

WSGIPythonPath /production/somelocation/django15/lib/python2.7/site-packages/
<VirtualHost 192.168.1.2:443>
        ....
        WSGIScriptAlias / /opt/project2.wsgi

My /opt/project.wsgi looks like

import os
import sys

# django1.2 virtualenv
import site
site.addsitedir("/production/somelocation/django12/lib/python2.4/site-packages")
.....

However when I go to the site I still get my default django (1.5) instance. What am I missing ?

like image 276
felix001 Avatar asked Dec 20 '22 02:12

felix001


2 Answers

The other answers mention setting the python path, however using WSGIPythonPath or WSGIPythonHome are not correct. The WSGIPythonPath / WSGIPythonHome can only be set server-wide, so no different paths per virtualhost.

You would want to use the WSGIDaemonProcess python-path and home arguments to set the python path and your apps home directory per virtualhost.

Also, within your code there is no need to adjust python paths; just make sure your virtualhost config is correct.

like image 143
Bouke Avatar answered Feb 08 '23 23:02

Bouke


You may need to set WSGIPythonHome since you have different Django installations.

WSGIPythonPath is used to define additional directories, but this option do not set default python installation. So probably, your default python directory also includes django (1.5) and recognize this version as the default django version. I do not know your python and django installation and configuration but this might be the reason.

Additional info for WSGIPythonHome

like image 36
FallenAngel Avatar answered Feb 09 '23 00:02

FallenAngel