[MERGE] Docs for configuring bzr WSGI with mod_python

Andrew Bennetts andrew at canonical.com
Wed Dec 13 06:01:42 GMT 2006


Hi all,

This bundle extends the existing http_smart_server.txt document to cover
configuring mod_python as well as mod_fastcgi.  It's purely a doc change.

I'm not totally happy with the result (it's hard to arrange text so that the
common bits aren't repeated without breaking the flow, whereas it's typically
easy with code...), but it's clear enough, I think.

-Andrew.

-------------- next part --------------
# Bazaar revision bundle v0.8
#
# message:
#   Describe smart server configuration with mod_python.
# committer: Andrew Bennetts <andrew.bennetts at canonical.com>
# date: Wed 2006-12-13 16:57:11.831000090 +1100

=== modified file doc/http_smart_server.txt
--- doc/http_smart_server.txt
+++ doc/http_smart_server.txt
@@ -6,7 +6,7 @@
 arbitrary files on your server.**
 
 This document describes one way to setup a Bazaar HTTP smart server, using
-Apache 2.0 and FastCGI.
+Apache 2.0 and FastCGI or mod_python.
 
 Example
 =======
@@ -21,6 +21,9 @@
 Configuring Apache 2.0
 ----------------------
 
+FastCGI
+~~~~~~~
+
 First, configure mod_fastcgi, e.g. by adding lines like these to your
 httpd.conf::
 
@@ -67,9 +70,48 @@
 .. _mod_rewrite: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
 .. _mod_fastcgi: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
 
+mod_python
+~~~~~~~~~~
+
+First, configure mod_python, e.g. by adding lines like these to your
+httpd.conf::
+
+    LoadModule python_module /usr/lib/apache2/modules/mod_python.so
+
+Define the rewrite rules with mod_rewrite the same way as for FastCGI, except
+change::
+
+    RewriteRule ^(.*)/\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
+
+to::
+
+    RewriteRule ^(.*)/\.bzr/smart$ /srv/example.com/scripts/bzr-smart.py
+
+Like with mod_fastcgi, we also define how our script is to be handled::
+
+    Alias /srv/example.com/scripts/bzr-smart.py /srv/example.com/scripts/bzr-smart.py
+    <Directory /srv/example.com/scripts>
+        <Files bzr-smart.py>
+            PythonPath "sys.path+['/srv/example.com/scripts']"
+            AddHandler python-program .py
+            PythonHandler bzr-smart
+        </Files>
+    </Directory>
+
+This instructs Apache to hand requests for any URL ending with `/.bzr/smart`
+inside `/code` to a Bazaar smart server via mod_python.
+
+Refer to the mod_python_ documentation for further information.
+
+.. _mod_python: http://www.modpython.org/
+
+
 Configuring Bazaar
 ------------------
 
+FastCGI
+~~~~~~~
+
 We've configured Apache to run the smart server at
 `/srv/example.com/scripts/bzr-smart.fcgi`.  This is just a simple script we need
 to write to configure a smart server, and glue it to the FastCGI gateway.
@@ -90,6 +132,29 @@
 
 .. _flup: http://www.saddi.com/software/flup/
 
+mod_python
+~~~~~~~~~~
+
+We've configured Apache to run the smart server at
+`/srv/example.com/scripts/bzr-smart.py`.  This is just a simple script we need
+to write to configure a smart server, and glue it to the mod_python gateway.
+Here's what it looks like::
+
+    import modpywsgi
+    from bzrlib.transport.http import wsgi
+
+    smart_server_app = wsgi.make_app(
+        root='/srv/example.com/code',
+        prefix='/code/',
+        path_var='REQUEST_URI')
+
+    modpywsgi.WSGIServer(smart_server_app).run()
+        
+The `modpywsgi` module can be found at http://trac.pocoo.org/wiki/ModPyWsgi.  It
+is part of pocoo_.
+
+.. _pocoo: http://trac.pocoo.org/wiki/
+
 Clients
 -------
 

=== modified directory  // last-changed:andrew.bennetts at canonical.com-200612130
... 55711-qsi87138y5udo707
# revision id: andrew.bennetts at canonical.com-20061213055711-qsi87138y5udo707
# sha1: 4f4c4cb95af0f3010cbdbb8c50e6225688fada23
# inventory sha1: 9e28f53f4eef78a7927c2f0447a66936ceb7e837
# parent ids:
#   pqm at pqm.ubuntu.com-20061213004620-1b7fef7dd0db37f0
# base id: pqm at pqm.ubuntu.com-20061213004620-1b7fef7dd0db37f0
# properties:
#   branch-nick: bzr



More information about the bazaar mailing list