Django and WSGI on Ubuntu
My virtual host Apache config snippet:
NameVirtualHost *
<VirtualHost *>
ServerName www.example.com
ServerAlias www.example.com
ServerAdmin admin@example.com
UseCanonicalName off
WSGIDaemonProcess www.example.com processes=2 threads=25
WSGIProcessGroup www.example.com
WSGIReloadMechanism Module
WSGIScriptAlias / /www/site/apache/django.wsgi
Alias /admin/media /path/to/django/contrib/admin/media
<Directory /path/to/django/contrib/admin/media>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Using the daemon process mode of WSGI means you can touch your Django WSGI file to restart the process serving your Django site instead of restarting Apache.
Here's my Django WSGI file:
import django.core.handlers.wsgi
import os, sys
sys.stdout = sys.stderr
sys.path.append('/path/to/django')
sys.path.append('/home/user')
os.environ['DJANGO_SETTINGS_MODULE'] = 'site.settings'
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
application = django.core.handlers.wsgi.WSGIHandler()
You can either permanently unzip and install Python eggs, or add a variable that points to the egg cache. You want to make sure the WSGI service account has write access there. Read the Django documentation and this page.