MoinMoin farming mode with apache2 and mod_wsgi

Why? Because MoinMoin is a widely used wiki, uses MoinMoin and I thought to keep a page with a guide to install the latest moinmoin version at the time I'm writing 2022-12-06

Basic idea

The basic idea is that in farming mode each wiki has it's own instance. For its own instance we mean data, configuration files, stylesheets and plugins Search on the online documentation of moinmoin I found

    config/   # contain the basic configurations common to all wikis       # site1         # site2
    plugin/          # systemwide plugins
    underlay/        # read-only doc
        pages/   #<--- need to be rwx for owner and group www-data
            data/    #<--- need to be rwx for owner and group www-data and so for
                plugin -> ../../../plugin

All the static content will be in the DocRoot of the webserver (e.g. /var/www/$(wikiname|hostname)/htdocs

At the end each host in the farm could have something like http://wherewerehome.nn/wiki/$(wikiname|hostname)/ with a rewrite rule (I'm might be totally wrong and a rewrite rule might not be usefull but I'm thinking in case of migration from server to server) in case of dedicated hostname, e.g. that point to http://wherewerehome.nn/wiki/$groupxy/

The apache2 setup

First check that libapache2-mod_wsgi or similar is installed, check that is loaded by apache ( a2enmod wsgi && apachectl restart )

This is my sample virtual host for the sum off all the wikis:

NameVirtualHost nnn.nnn.nnn.nnn
<VirtualHost thefarm>
        ServerAdmin webmaster@thefarm
        ServerName thefarm

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        #This is for FCKeditor and goes 1st cause is longer than the next alias (it doesn't work otherwise)
        Alias /moin_static/applets/FCKeditor/ "/usr/share/fckeditor/"

        # Static data, styleshets and images
        Alias /moin_static /var/www/wiki/htdocs

        # WSGIScriptAlias /wiki /home/wiki/bin/moin.wsgi
        # match rules for multihoming, multihoming won't work without
        WSGIScriptAliasMatch ^/wiki/([^/]+) /home/wiki/bin/moin.wsgi

        # create some wsgi daemons - use someuser.somegroup same as your data_dir:
        WSGIDaemonProcess wiki user=wiki group=wiki home=/home/wiki processes=5 threads=10 maximum-requests=1000
        # umask=0007 does not work for mod_wsgi 1.0rc1, but will work later

        # use the daemons we defined above to process requests!
        WSGIProcessGroup wiki

        # this is here because I'm integrating moinmoin in various frameworks(RoR,django,phpcake) and I had to be sure that the wiki dir is handled only by moinmoin
        <Location /wiki>
                SetHandler None

        # this is for the basic
        <Location /moin_static>
                SetHandler None
        <Directory /var/www/moin/htdocs>
                Order allow,deny
                Allow from all

        # this is for the multihoming
        # now don't need to restart apache when adding new wikis :)
        # could do the same trick to run custom moin.wsgi

        Alias /moin_([^/]+) /home/wiki/wikis/([^/]+)/htdocs
        <DirectoryMatch ^/home/wiki/wikis/([^/]+)/>
                Order deny,allow
                Allow from all

        ErrorLog /var/log/apache2/stargate1-error.log

        LogLevel warn

        CustomLog /var/log/apache2/stargate1-access.log combined


The instance

I adjusted a script to arrange the wikis, it only add a wiki, it should make snapshots of data and config. Whould be possible to have the data in dated tarballs and configs via git.

--- not tested yet ---

This is

# path of MoinMoin shared files

# path to target instance location

# should be nice

if [ ! $1 ]
  echo "You must specify an instance (relative or absolute path)"
  echo "You can also specify --withdocs to have a copy of moin docs in instance"

if [[ -e $1 || -d $1 ]]
  echo "$1 already exists"

cp -va $BASE/data $WIKIS/$INSTANCE

if [ $2 = "--withdocs" ]; then
   cp -va $BASE/underlay $WIKIS/$INSTANCE

cp -v $BASE/config/ $BASE/config/$

chmod -R ug+rwX $WIKIS/$INSTANCE
chmod -R o-rwx $WIKIS/$INSTANCE

if [ $? ]
  echo "Done."
  echo "Something went wrong :P"

This script could be extend also for backup/restore, move to remote farm, import from remote farm

MoinMoinFarmingApache2WSGI (last edited 2010-07-20 17:47:25 by anonymous)