Todd O'Bryan

Using mod_wsgi with a path-based farm

You'd like to use mod_wsgi to create a wikifarm, but you want your wikis to be signaled by their path on the server, rather than which virtual host they belong to. So did I, and it took me a while to figure it out, so hopefully my pain will help you out.

I started out with a set of wikis that were already working under mod_python. I needed to upgrade to a new version of Moin. Not being great at following the upgrade directions, I managed to create quite a mess and decided to give mod_wsgi a try.

Here's my setup. I have a single farmconfig.py with the following entries:

wikis = [
    # Standalone server needs the port e.g. localhost:8000
    # Twisted server can now use the port, too.
    
    # wikiname,     url regular expression (no protocol)
    # ---------------------------------------------------------------
    ('abc',  r'^www.server.org/wikis/abc(/.*)?$'),
    ('def',  r'^www.server.org/wikis/d(/.*)?$'),
    ('ghi',  r'^www.server.org/wikis/random_name(/.*)?$'),
]

In the same directory, I have abc.py, def.py, and ghi.py files where I set the data_dir for each wiki.

What does this mean? Please show an example of e.g. abc.py

In the same directory (though you could put it somewhere else), I also copied moin.wsgi from the /wiki/server directory in the MoinMoin download and added an entry

sys.path.insert(0, '/path/to/farm_config/directory')

In my Apache configuration I have the following:

WSGIDaemonProcess moin
WSGIScriptAliasMatch /wikis/[^/]+ /path/to/moin.wsgi
<LocationMatch /wikis/[^/]+>
        WSGIProcessGroup moin
        WSGIApplicationGroup %{GLOBAL}
</LocationMatch>

Alias /moin_staticXXX /path/to/moin/htdocs
<Directory /path/to/moin/htdocs>
        Order allow,deny
        Allow from all
</Directory>

(Obviously change all the /path/to paths as appropriate for your setup.)

A couple of things to note here. The regular expression in the LocationMatch directive matches the common path of the URL along with the part that identifies which wiki in the farm to use. This only works because all of the wikis are contained in a single path on the server and the part of the URL that represents the wiki (abc, d, and random_name, in my example) doesn't contain a slash. If you're okay with those limitations, this should work.


CategoryHomepage

MoinMoin: ToddOBryan (last edited 2009-01-07 04:16:03 by ToddOBryan)