Apache 2 Django Application Configuration

This template helps create apache 2 configurations for django applications using mod_python. The assumed structure is that "/var/www/" is the base path and that sites exist in a directory such as "/var/www/%[app_name]%/. This file should be placed named %[fqdn]% and placed in /var/www/sites-available. After this file is saved you should issue a2ensite %[fqdn]% then restart apache.

February 16, 2012

<VirtualHost *:80>
        ServerAdmin %{admin_email_address}%
        ServerName  %{fqdn}%
        ServerAlias %{site_alias}%

        # Indexes + Directory Root.
        DocumentRoot /var/www/%{fqdn}%/%{app_name}%/

        ErrorLog  /var/www/%{fqdn}%/logs/error.log
        CustomLog /var/www/%{fqdn}%/logs/access.log combined
<Location />
            SetHandler python-program
            PythonHandler django.core.handlers.modpython
            PythonPath "['/var/www/%{fqdn}%','/var/www/%{fqdn}%/%{app_name}%'] + sys.path"
            PythonOption django.root /%{app_name}%
            SetEnv DJANGO_SETTINGS_MODULE %{app_name}%.settings
            PythonDebug on

<Location /media>
        SetHandler None

<Location /admin-media>
        SetHandler None

<Location /static>
        SetHandler None