Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Django applications using virtualenv on Apache 2 on Ubuntu 11

I've successfully setup one Django application using virtualenv on Ubuntu and Apache 2, using the WSGIPythonHome directive pointing to my virtualenv location. Now I am in need to create a separate Django application, that is going to run on Apache on a different port on the same Ubuntu server. I am wondering if there's a way to have Apache run multiple WSGIPythonHome instances? Currently with WSGIPythonHome being set to one virtualenv root, there's a problem with imports on the second Django app…

like image 743
Sam Hammamy Avatar asked Nov 04 '22 02:11

Sam Hammamy


1 Answers

The best way to do this, I've discovered about a year ago, is to use WSGI as a daemon and set the python path in the daemon directive. Example is below

<VirtualHost *:80>
    ServerName yourhost.com

    <Directory />
      Order deny,allow
      #Require all granted
    </Directory>

    #Alias /static /opt/yourhost/static
    WSGIScriptAlias / /opt/yourhost/wsgi.py

    WSGIApplicationGroup %{GLOBAL}

    WSGIDaemonProcess yourhost.com python-path=/opt/yourhost:/opt/yourhost/venv/lib/python2.7/site-packages processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup  yourhost.com
</VirtualHost>
WSGISocketPrefix /var/run/wsgi
like image 155
Sam Hammamy Avatar answered Nov 15 '22 05:11

Sam Hammamy