Skip to content

Instantly share code, notes, and snippets.

@nspo
Created March 30, 2018 20:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nspo/715968bbbca473d674ecc78e40d8cb46 to your computer and use it in GitHub Desktop.
Save nspo/715968bbbca473d674ecc78e40d8cb46 to your computer and use it in GitHub Desktop.
Running multiple Django projects on one Apache instance with mod_wsgi
STATIC_URL = '/site1/static/'
# adjust name of session id
SESSION_COOKIE_NAME = "site1"
STATIC_URL = '/site2/static/'
# adjust name of session id
SESSION_COOKIE_NAME = "site2"
# /etc/apache2/sites-available/site1-site2.conf
WSGIDaemonProcess site1 python-home=/var/www/site1 python-path=/var/www/site1
WSGIProcessGroup site1
WSGIDaemonProcess site2 python-home=/var/www/site2 python-path=/var/www/site2
WSGIProcessGroup site2
# works with SSL too
<VirtualHost *:80>
Alias /site1/static/ /var/www/site1/myapp/static/
<Directory /site1/static>
Require all granted
</Directory>
WSGIScriptAlias /site1 /var/www/site1/myproj/wsgi.py process-group=site1
<Directory /var/www/site1/myproj>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /site2/static/ /var/www/site2/myapp/static/
<Directory /site2/static>
Require all granted
</Directory>
WSGIScriptAlias /site2 /var/www/site2/myproj/wsgi.py process-group=site2
<Directory /var/www/site2/myproj>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
@brygator
Copy link

Very good, very helpful! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment