Apache2 mod_wsgi for django

A simple template to setup a django site for apache2 and mod_wsgi.

akonkol
February 16, 2012




%{---Apache file located at: /etc/apache2/sites-available/%{site_fqdn}%---}%
<VirtualHost *:80>
        ServerAdmin %{admin_email}%
        ServerName  %{site_fqdn}%
        ServerAlias %{site_alias}%

        # Indexes + Directory Root.
        DocumentRoot /var/www/%{site_fqdn}%/%{project_name}%/

        ErrorLog  /var/www/%{site_fqdn}%/logs/error.log
        CustomLog /var/www/%{site_fqdn}%/logs/access.log combined

Alias /robots.txt /var/www/%{site_fqdn}%/%{project_name}%/media/robots.txt
Alias /media/ /var/www/%{site_fqdn}%/%{project_name}%/media/
Alias /admin-media/ /var/www/%{site_fqdn}%/%{project_name}%/admin-media/


WSGIScriptAlias / /var/www/%{site_fqdn}%/%{project_name}%/%{site_fqdn}%.wsgi
WSGIDaemonProcess %{project_name}% user=www-data group=www-data processes=1 threads=10
WSGIProcessGroup %{project_name}%

</VirtualHost>


%{---wsgi file located at: /var/www/%{site_fqdn}%/%{project_name}%/%{site_fqdn}%.wsgi ---}%


import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = '%{project_name}%.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()