4

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 ?

4 Answers 4

8
+50

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.

Sign up to request clarification or add additional context in comments.

6 Comments

I was talking about python-path, as you just said. See my second answer, since I couldn't access my httpd-vhost file until now.
Thanks, Ive used the WSGIDaemonProcess and this works however, Im not setting a user or group and then using "WSGIApplicationGroup %{GLOBAL}".So Im not sure if this is a security concern ?
You should not do this when hosting multiple sites on the same machine. You can use user and group arguments to set the user/group as which the WSGI should be executed.
Could you please decide who gave you the proper answer? Thanks.
Ok thanks, so you would you use user1/group1 for site A and user2/group2 for site B ? Thanks for all your help....
|
1

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

Comments

1

This is how I do with Pyramid:

<VirtualHost *:80>
    Servername hackintosh
    DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>


<VirtualHost *:80>
    ServerName modwebsocket.local
    ErrorLog "/PythonProjects/MOD_WEBSOCKET/logs/error_log"
    CustomLog "/PythonProjects/MOD_WEBSOCKET/logs/access_log" common

    WSGIDaemonProcess pyramid-modwebsocket user=apero group=staff threads=4 python-path=/PythonProjects/MOD_WEBSOCKET/lib/python2.7/site-packages
    WSGIProcessGroup pyramid-modwebsocket

    WSGIScriptAlias /  /PythonProjects/MOD_WEBSOCKET/wsgi/pyramid.wsgi

    <Directory "/PythonProjects/MOD_WEBSOCKET/wsgi">
        WSGIProcessGroup pyramid-modwebsocket
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:80>
    ServerName ai.local
    ErrorLog "/PythonProjects/AI/logs/error_log"
    CustomLog "/PythonProjects/AI/logs/access_log" common

    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    WSGIDaemonProcess pyramid-ai user=apero group=staff threads=4 python-path=/PythonProjects/AI/lib/python2.7/site-packages
    WSGIProcessGroup pyramid-wizard

    WSGIScriptAlias /  /PythonProjects/AI/wsgi/pyramid.wsgi

    <Directory "/PythonProjects/AI/wsgi">
        WSGIProcessGroup pyramid-ai
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

1 Comment

So, did this and my initial abswer, solve your issue? If yes thanks for giving points.
1

This topic and the typical causes are detailed in:

There is not enough information in your question to properly evaluate which of the problems you are encountering.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.