]> git.ozlabs.org Git - patchwork/commitdiff
lib/apache2: Add WSGI Handler
authorMartin Krafft <madduck@madduck.net>
Sun, 31 Jan 2010 01:32:45 +0000 (02:32 +0100)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 10 Aug 2010 03:49:35 +0000 (11:49 +0800)
Patchwork/Django can be run directly with WSGI, which is bound to be
faster and less complex than FastCGI. This patch provides the necessary
Apache configuration and the WSGI handler, as well as an update to the
docs.

Since python-flup is deprecated and WSGI supersedes FastCGI, it should
be(come) the preferred method. Hence I documented it first.

For the xmlrpc interface to work with WSGI, the HTTP authorization
information needs to be passed to the WSGI handler. This is done by
setting WSGIPassAuthorization On in the apache2 config file snippet.

Ref: http://www.arnebrodowski.de/blog/508-Django,-mod_wsgi-and-HTTP-Authentication.html

Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
docs/INSTALL
lib/apache2/patchwork.wsgi [new file with mode: 0644]
lib/apache2/patchwork.wsgi.conf [new file with mode: 0644]
patchwork.wsgi [new symlink]

index 7a32434688cdd7f2393fec58eaeb7e10f27e1dfa..82b6694dccc4bc4a57690029d9f5be77d2642ee3 100644 (file)
@@ -153,10 +153,22 @@ in brackets):
 
 Example apache configuration files are in lib/apache/.
 
+wsgi:
+        django has built-in support for WSGI, which supersedes the fastcgi
+        handler. It is thus the preferred method to run patchwork.
+
+        The necessary configuration for Apache2 may be found in
+
+         lib/apache2/patchwork.wsgi.conf.
+
+        You will need to install/enable mod_wsgi for this to work:
+
+         a2enmod wsgi
+         apache2ctl restart
+
 mod_python:
 
-        This should be the simpler of the two to set up. An example apache
-        configuration file is in:
+        An example apache configuration file for mod_python is in:
 
           lib/apache/patchwork.mod_python.conf
 
diff --git a/lib/apache2/patchwork.wsgi b/lib/apache2/patchwork.wsgi
new file mode 100644 (file)
index 0000000..0488b48
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Apache2 WSGI handler for patchwork
+#
+# Copyright © 2010 martin f. krafft <madduck@madduck.net>
+# Released under the GNU General Public License v2 or later.
+#
+import os
+import sys
+
+basedir = os.path.dirname(__file__)
+sys.path.append(basedir)
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'apps.settings'
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()
diff --git a/lib/apache2/patchwork.wsgi.conf b/lib/apache2/patchwork.wsgi.conf
new file mode 100644 (file)
index 0000000..e99f8c6
--- /dev/null
@@ -0,0 +1,20 @@
+<IfModule mod_alias.c>
+        Alias /images/ "/srv/patchwork/htdocs/images/"
+        Alias /css/ "/srv/patchwork/htdocs/css/"
+        Alias /js/ "/srv/patchwork/htdocs/js/"
+        Alias /robots.txt "/srv/patchwork/htdocs/robots.txt"
+        <Directory "/srv/patchwork/htdocs">
+                Order allow,deny
+                Allow from all
+        </Directory>
+
+        Alias /media/ "/usr/share/python-support/python-django/django/contrib/admin/media/"
+
+        <Directory "/usr/share/python-support/python-django/django/contrib/admin/media/">
+                Order allow,deny
+                Allow from all
+        </Directory>
+</IfModule>
+
+WSGIScriptAlias / "/srv/patchwork/patchwork.wsgi"
+WSGIPassAuthorization On
diff --git a/patchwork.wsgi b/patchwork.wsgi
new file mode 120000 (symlink)
index 0000000..cf13d18
--- /dev/null
@@ -0,0 +1 @@
+lib/apache2/patchwork.wsgi
\ No newline at end of file