I am working on my first Django project and would like to get comments on a reasonable layout for a single Django instance used with several Django projects where:
1. each project is a single web site on a unique virtual host (vhost) 2. all virtual hosts are on a single, real server running Debian 7 3. the real server is running a single Apache 2.4.7 (soon to be 2.4.8) instance 4. each virtual host using Django will be SSL/TLS only or non-SSL/TLS (i.e., no mixed traffic ports at any one vhost) Basically I would like to associate the project names with the virtual host domain names, for example: domain => project ============ domain1.com => domain1 domain2.com => domain2 I would also like to share common things between sites as much as possible. Attached is a file showing the appropriate Apache httpd.conf section illustrating my proposed vhost macro. Note that the projects are all under: /web-sites/${project}.${tld}/cgi-bin/${project} so that that the Python base project name does not have a dot to confuse Python treatment as a module. Does anyone see any problems with this layout (except obvious lack of common Python code treatment)? I think it will be fairly easy to re-factor common code later. Comments welcome. Best regards, -Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFMGiz86WywcSsS-kVV_cZK%2Bjzg6OKfDpTe%2BE%3DqGwEni7mmtQA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
# use Apache's mod_macro: # define a VHost Macro for repetitive configurations # domain name convention: ${project}.${tld} (e.g., "example.com") <Macro VHOST_NONSSL $project $tld> <VirtualHost *:80> # A Django site using mod_wsgi ServerName ${project}.${tld} ServerAlias www.${project}.${tld} DocumentRoot /web-sites/${project}.${tld}/public # serving static files Alias /robots.txt /web-sites/${project}.${tld}/public/robots.txt Alias /favicon.ico /web-sites/${project}.${tld}/public/favicon.ico AliasMatch ^/([^/]*\.css) /web-sites/${project}.${tld}/public/styles/$1 Alias /media/ /web-sites/${project}.${tld}/public/media/ Alias /static/ /web-sites/${project}.${tld}/pubic/static/ Alias /admin/ /virtualenvs/myfirstenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/ <Directory /web-sites/${project}.${tld}/public/static> Order deny,allow Require all granted </Directory> <Directory /web-sites/${project}.${tld}/public/media> Order deny,allow Require all granted </Directory> # mod_wsgi handles below here # See notes in: # http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide # http://code.google.com/p/modwsgi/wiki/ConfigurationIssues # https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi WSGIScriptAlias / /web-sites/${project}.${tld}/${project}/wsgi.py # using daemon mode WSGIDaemonProcess ${project}.${tld} python-path=/web-sites/${project}.${tld}/cgi-bin/${project} python-home=/virtualenvs/myfirstenv/lib/python2.7 WSGIProcessGroup ${project}.${tld} WSGIProcessGroup %{GLOBAL} WSGIApplicationGroup %{GLOBAL} <Location "/secret"> AuthType Basic AuthName "Top Secret" Require valid-user AuthBasicProvider wsgi WSGIAuthUserScript /web-sites/${project}.${tld}/cgi-bin/${project}/wsgi.py </Location> <Directory /web-sites/${project}.${tld}/cgi-bin/${project}> <Files wsgi.py> Order deny,allow Require all granted </Files> </Directory> </VirtualHost> </Macro> Use VHOST_NONSSL domain1 com Use VHOST_NONSSL domani2 org UndefMacro VHOST_NONSSL