Deploying multiple django apps on Apache with mod_wsgi Deploying multiple django apps on Apache with mod_wsgi django django

Deploying multiple django apps on Apache with mod_wsgi


This is a problem with the wsgi.py file generated by Django 1.4. It will not work where trying to host two distinct Django instances in the same process, even though in separate sub interpreters.

Change:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "site1.settings")

to:

os.environ["DJANGO_SETTINGS_MODULE"] = "site1.settings"

Or better still use daemon mode and delegate each to run in distinct daemon process groups.

That is, instead of:

WSGIScriptAlias /site1 /var/www/py/site1/site1/wsgi.pyWSGIScriptAlias /site2 /var/www/py/site2/site2/wsgi.pyWSGIPythonPath /var/www/py/site1:/var/www/py/site2

use:

WSGIDaemonProcess site1 python-path=/var/www/py/site1WSGIScriptAlias /site1 /var/www/py/site1/site1/wsgi.py process-group=site1 application-group=%{GLOBAL}WSGIDaemonProcess site2 python-path=/var/www/py/site2WSGIScriptAlias /site2 /var/www/py/site1/site2/wsgi.py process-group=site2 application-group=%{GLOBAL}

UPDATE

Note that there is a whole blog post about this and other causes now.


Your apps listen on the same port, and there doesn't seem to be a proxy that delegates them to different ones.

You either have to setup VirtualHosts within apache or use Nginx, lighttpd or something else to create a proper proxy


Graham Dumpleton's response is the one you probably want to read closest, but I would suggest saving yourself a lot of heartburn by hosting your two Djangos at the root of different subdomains rather than at non-root locations on the same domain. There are lots of gotchas for running non-root Django sites IMHO.

Good luck!