Creating a MoinMoin Wiki Instance
This article describes how to set up a wiki on apache2 using mod-python and mod-rewrite for pretty URLs.
cite: Wiki Instance Creation
Software
You'll need python-moinmoin, apache2, and libapache2-mod-python. Your package manager should pull in the rest of the dependencies, once these are installed.
Creating the Environment
Make a directory somewhere that will house the wiki. It is not recommended that you place the wiki files somewhere inside a directory that apache might serve as a webpage so that if there is a failure (if mod-python gets uninstalled, for instance) the wiki pages won't be served vanilla to the public.
Suppose you are installing creating a wiki for 'wiki.foo.org' and putting it in /var/wiki/:
cd /var/wiki/ mkdir wiki.foo.org cp -R /usr/share/moin/data wiki.foo.org/ cp -R /usr/share/moin/underlay wiki.foo.org/ cp /usr/share/moin/config/wikiconfig.py wiki.foo.org/ # give the webserver ownership chown -R www-data.www-data wiki.foo.org # give webserver r/w access chmod -R ug+rwx wiki.foo.org # limit other accesses chmod -R o-rwx wiki.foo.org
Configuring the new Wiki
Now that we have the directory set up with all the data we need, we have to do some configuration. The first thing we should configure is the wiki itself, so that when we configure apache to serve it, we'll get something. Edit wiki.foo.org/wikiconfig.py
1 class Config(DefaultConfig):
2 # The name of the wiki
3 sitename = u'Some New Wiki'
4
5 # This is usually fine
6 logo_string = sitename
7
8 # Be sure to uncomment option b)!
9 page_front_page = u"FrontPage"
10
11 # This isn't very important, but you want
12 # it to lack spaces and be your sitename
13 interwikiname = ''.join(sitename.split())
14
15 # Datadir Configuration: IMPORTANT
16 # - use absolute paths here!
17
18 data_dir = /var/wiki/wiki.foo.org/data/
19 data_underlay_dir = /var/wiki/wiki.foo.org/underlay/
20
21 # url_prefix is fine at '/wiki'; we're going to rewrite anyway
22 url_prefix = '/wiki'
23
24 # add the account you plan to create as an admin
25 superuser = [u"yourname", u"anotheradmin"]
26 acl_rights_before = u"yourname:read,write,delete,revert,admin"
27
28 # disable mail unless you need it
29 mail_enabled = False
Configuring Apache
Add the following lines to the apt virtual host in whatever apache configuration file that you are adding this wiki to. In our example, we're going to create our own virtual host wiki.foo.org, so in /etc/apache2/sites-available/1_wiki.foo.org (your file will vary):
<VirtualHost *>
ServerName wiki.foo.org
ServerAdmin yourname@foo.org
DocumentRoot /var/wiki/wiki.foo.org
RewriteEngine On
RewriteLogLevel 0
RewriteRule ^/wiki/(.*)$ /usr/share/moin/htdocs/$1 [last]
RewriteRule ^(.*)$ /var/wiki/wiki.foo.org/moinmodpy.py$1
Alias /wiki/ "/usr/share/moin/htdocs/"
<Directory "/var/wiki/wiki.foo.org">
Options FollowSymLinks
AllowOverride All
SetHandler python-program
PythonPath "['/var/wiki/wiki.foo.org'] + sys.path"
PythonHandler MoinMoin.request::RequestModPy.run
</Directory>
</VirtualHost>Please note that we've set the DocumentRoot as /var/www/wiki.foo.org, even though this is our wiki location. In theory, this is bad. If your wiki is important, please tell apache to go somewhere else (such as an empty subdirectory within your wiki).
The first RewriteRule line rewrites requests to /wiki/ to look in /usr/share/moin/htdocs/ instead. The second RewriteRule rewrites requests to the webroot. I'm not even sure if this or the Alias line are necessary: do some research?
The <Directory ...> directive is only important for the SetHandler and Python.. lines. The SetHandler tells apache to use mod-python for this Directory. PythonPath "['/var... adds our wiki's directory to the path, which is important, because MoinMoin is going to want to find our wikiconfig.py file. Finally, PythonHandler ... sets the handler to the MoinMoin mod-python handler; this line needn't be changed per installation.
.