I want to deploy two different django apps in the same host: The first will correspond to the url /site1 and the second to the url /site2. Here\'s my configuration:
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
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.py
WSGIScriptAlias /site2 /var/www/py/site2/site2/wsgi.py
WSGIPythonPath /var/www/py/site1:/var/www/py/site2
use:
WSGIDaemonProcess site1 python-path=/var/www/py/site1
WSGIScriptAlias /site1 /var/www/py/site1/site1/wsgi.py process-group=site1 application-group=%{GLOBAL}
WSGIDaemonProcess site2 python-path=/var/www/py/site2
WSGIScriptAlias /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.
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!