Reputation: 44351
I am deploying a web2py
application, and I will be serving it with Apache
via mod_wsgi
. I have the following WSGI directives in my virtual host configuration:
WSGIDaemonProcess web2py user=www-data group=www-data \
display-name=%{GROUP}
WSGIProcessGroup web2py
WSGIScriptAlias / /var/www/web2py/wsgihandler.py
This is working, but it is taking the system wide python installation. As a result, some packages are not found (since they are only present in my virtualenv). I would like to tell this particular virtual host (or the whole Apache, if there is no other way), to use the python installation in my virtual environment (/home/myuser/.virtualenvs/python2.7.2/bin
).
Is it possible to configure this for Apache? Or better, just for my virtual host? I would like to cause as little effect as possible to the rest of the system (specifically, I do not want to modify the default python version used system wide)
Upvotes: 2
Views: 1108
Reputation: 43077
In your wsgihandler.py
add this at the top...
activate_this = '/path/to/virtualenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this)
import sys
sys.path.insert(0, '/path/to/web2py_dir')
Upvotes: 3