Commits

Vincent Hillenbrink  committed 14b5f7a

Rewrotescripts/create_apache_vhost_conf.sh documentation

  • Participants
  • Parent commits 3fcd6f5

Comments (0)

Files changed (1)

File scripts/create_apache_vhost_conf.sh

 #!/bin/sh
 #
-# Generates Apache virtual host configuration for reverse proxying
-# runserver instances.
+# Generates Apache named virtual host configuration for reverse
+# proxying runserver instances, to be included from your Apache
+# configuration.
 #
-# Experimental.
+# This way, you can have unlimited Django runserver instances running
+# at the same time, each one listening on a different port as specified
+# in the settings. This makes life easier when working with multiple
+# Django projects simultaneously, but it also allows comparison between
+# different settings within a single Django project, for instance the
+# performance of two different database backends.
 #
-# To be run in an activated django-environment environment, i.e.
-# $PROJECT_ROOT must be set correctly.
+# Either set settings.LOCAL_SERVER_PORT to the port you want to use
+# for a given Django project (in settings/generic.py), and optionally
+# overrule settings.LOCAL_SERVER_PORT in a specific environment
+# settings file, like settings/env/dev_postgress.py. (It's a good
+# idea to have a port numbering strategy ready before you start, just
+# like with BASIC line numbers: 7000-7099 project A, 7100-7199 project
+# B and so on.)
+#
+# By default, the generated virtual hosts will have the naming formats
+# 'django_project_id.local' and 'settings_id.django_project_id.local'.
+# By defining environment variable $DOMAIN you can change the domain
+# postfix to anything you like, for instance
+# 'development.myorganization.dom'.
+#
+# Steps to get this working:
+#
+# 1. Run this scripts and save the output to a file, for instance
+#    create_apache_vhost_conf.sh > $PROJECT_ROOT/deploy/vhosts-development.conf
+#    (It's good idea to do this in a VCS hook to always keep it up-to-date.)
+#
+# 2. Include the configuration file in your Apache configuration:
+#    Include /Users/spanky/repos/myproject/deploy/vhosts-development.conf
+#
+# 3. Restart Apache.
+#
+# 4. For each of the generated virtual hosts you wish to use, add
+#    the host name to the localhost entry in /etc/hosts:
+#    127.0.0.1 localhost django_project_id.local
+#
+#    Or, even better: use a DNS server that supports wildcards! This
+#    way you simply have to make sure that *.development.myorganization.dom
+#    points to 127.0.0.1, and you're done.
+#
+# 5. Use 'djenv django_project_id settings_id', followed by 'runserver'
+#    to have a Django server listening at the port you specified in the
+#    setings. Note you will have to use the 'runserver' function as
+#    provided by django-environments to have the server actually listen
+#    on settings.LOCAL_SERVER_PORT.
+#
+# 6. Go to the appropriate URL, e.g.
+#    http://settings_id.django_project_id.local/ and admire your work.
 
 domain=local
 [ ! -z "$DOMAIN" ] && domain=$DOMAIN
         echo '#' $django_project
         export PYTHONPATH=`dirname $django_project_dir`
         export DJANGO_SETTINGS_MODULE=$django_project.settings
-        port=`get_django_setting LOCAL_SERVER_PORT`
+        port=`get_django_setting LOCAL_SERVER_PORT 8000`
 
         cat << EOF
 <VirtualHost 127.0.0.1:*>
 
             export PYTHONPATH=`dirname $django_project_dir`
             export DJANGO_SETTINGS_MODULE=$django_project.$django_settings
-            port=`get_django_setting LOCAL_SERVER_PORT`
+            port=`get_django_setting LOCAL_SERVER_PORT 8000`
 
             cat << EOF
 <VirtualHost 127.0.0.1:*>