Skip to content

Instantly share code, notes, and snippets.

@turtlemonvh
Created June 25, 2014 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turtlemonvh/2a42e58be8b238aa80fd to your computer and use it in GitHub Desktop.
Save turtlemonvh/2a42e58be8b238aa80fd to your computer and use it in GitHub Desktop.
Apache conf for multiple djangos at subdomains
# Some tips:
# - tips on multiple versions: http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi
# - using the wsgi daemon mode allows better performance with multi-threading
WSGISocketPrefix /var/run/wsgi
Alias /err/ "/var/www/error/"
ErrorDocument 404 /err/HTTP_NOT_FOUND.html.var
# The default virtual host
# Returns an error if the exact subdomain isn't found
<VirtualHost *:80>
ServerName site_not_found
RedirectMatch 404 ^/(?!err)
</VirtualHost>
# The subdomain
<VirtualHost *:80>
ServerName simv2test.myapp.com
ServerAlias simv2test.myapp.com
Alias /favicon.ico /var/www/deploy/appname_simv2test/appname/site_media/static/img/favicon.ico
Alias /site_media/media/ /var/www/deploy/appname_simv2test/appname/site_media/media/
Alias /site_media/static/ /var/www/deploy/appname_simv2test/appname/site_media/static/
<Directory /var/www/deploy/appname_simv2test/appname/site_media/static>
Options FollowSymLinks
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/deploy/appname_simv2test/appname/site_media/media>
Options FollowSymLinks
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess AppnameSimv2test user=apache group=apache threads=25 python-path=/usr/lib64/python2.6/site-packages:/var/www/deploy/appname_simv2test/appname
WSGIProcessGroup AppnameSimv2test
WSGIScriptAlias / /var/www/deploy/appname_simv2test/appname/wsgi.py
<Directory /var/www/deploy/appname_simv2test/appname >
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName myapp.com
ServerAlias myapp.com
Alias /favicon.ico /var/www/deploy/appname/appname/site_media/static/img/favicon.ico
Alias /site_media/media/ /var/www/deploy/appname/appname/site_media/media/
Alias /site_media/static/ /var/www/deploy/appname/appname/site_media/static/
<Directory /var/www/deploy/appname/appname/site_media/static>
Options FollowSymLinks
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/deploy/appname/appname/site_media/media>
Options FollowSymLinks
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess Appname user=apache group=apache threads=25 python-path=/usr/lib64/python2.6/site-packages:/var/www/deploy/appname/appname
WSGIProcessGroup Appname
WSGIScriptAlias / /var/www/deploy/appname/appname/wsgi.py
<Directory /var/www/deploy/appname/appname >
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment