pantz.org banner
Setting up a MoinMoin wiki
Posted on 04-15-2009 17:25:39 UTC | Updated on 08-01-2010 04:18:33 UTC
Section: /software/moinmoin/ | Permanent Link

This will will be an example of an install of the MoinMoin wiki on CentOS 5. MoinMoin needs Python 2.4 to run. This install will look like a local desktop install but utilize a wiki farm configuration (multiple wiki's). The wiki (MoinMoin) will run using it's own internal webserver. Each wiki will need to have it's own host name. This is how MoinMoin separates wiki's. They will all share the same ip. The primary A record in DNS is just put in as something like wiki.yourserver.org. Then a CNAME is put in for each wiki after that pointing to wiki.yourserver.org. MoinMoin will look at the host header of each request and direct the request to the correct wiki based on it.

I'm sure this install can be done on any other Linux distro so just adapt it as you need to. One thing to remember when dealing with MoinMoin files is that they are written in Python so line spacing matters! I choose MoinMoin over other wiki's because it can run on it's own built in webserver. It also lives in it's own directory so backing it up is easy. The wiki language it uses is simple and you can export the pages to static html pages. The internal webserver can not handle a high load of people but for a small group it is great. You can export the static pages to a main website in a read-only fashion for all in a nice fast static format. That just happened to be my requirements but yours may be different.

Install MoinMoin

Switch to the dir you want the MoinMoin dir to be in. We will use /disk01 for the example. Then download the MoinMoin tarball from the website. This install will use MoinMoin 1.8.2.

cd /disk01
wget http://static.moinmo.in/files/moin-1.8.2.tar.gz

Untar it and change the name of the dir. Move the tar file to the MoinMoin dir.

tar xvzf moin-1.8.2.tar.gz
mv moin-1.8.2 moinmoin
mv moin-1.8.2.tar.gz moinmoin

Add the user moinmoin to the system. This is the user the server and group the user will run as.

adduser -M moinmoin -s /sbin/nologin

Edit the file wikiserverconfig.py in the main MoinMoin dir. This file has the default settings the server will start with. We will change the port to 80 and bind to an ip on the interface of the workstation. My example will use the ip 192.168.0.245. Your ip will be different. Change the ip to 127.0.0.1 if you just want to test the wiki locally. We will also have the server run as the user and group moinmoin. After editing the file save and exit. The parts we are interested in will look like the following after we are done.

    port = 80 # if you use port < 1024, you need to start the server as root
    user = 'moinmoin'
    group = 'moinmoin'
    interface = '192.168.0.245'

Update for MoinMoin 1.9.x: Running MoinMoin as root with user and group like in the settings above used to bind to a low port (80) and then switch the daemon to the set user and group in 1.8.x. Currently I have not been able to get 1.9.3 to do this. It fails with "socket.error: (13, 'Permission denied')". I have not looked into this further.

Copy the farmconfig.py file to the main dir so we can do a wikifarm. Then give the moinmoin user ownership of all the files.

cp /disk01/moinmoin/wiki/config/wikifarm/farmconfig.py /disk01/moinmoin
chown -R moinmoin: /disk01/moinmoin/

Configure a wiki

This is how to make a new wiki for the MoinMoin wiki farm. Wiki farm is just the name for one MoinMoin install to be able to serve out multiple wiki's. After the initial MoinMoin install (above) this is how you will add each wiki. The example will use the name wiki1 as the first wiki's name.

Make the wiki's dir (use the wiki name). Copy the default files into the dir. Give correct ownership and permissions.

mkdir -p /disk01/moinmoin/wiki/wiki1
mkdir -p /disk01/moinmoin/wiki/wiki1/data/user
cp -R /disk01/moinmoin/wiki/data /disk01/moinmoin/wiki/wiki1
cp /disk01/moinmoin/wiki/config/wikiconfig.py /disk01/moinmoin/wiki/wiki1
chown -R moinmoin.moinmoin /disk01/moinmoin/wiki/wiki1
chmod -R ug+rwX /disk01/moinmoin/wiki/wiki1
chmod -R o-rwx /disk01/moinmoin/wiki/wiki1

Now we will make the config file for the new wiki. The name of the config file needs to be the name of the wiki with the file extention .py on the end. So our file will be called wiki1.py. It needs to be located in the main MoinMoin install dir. For our install that would be /disk01/moinmoin/. Open a new file in the main dir called wiki1.py. The info we are going to put in is overriding some of the config information in the farmconfig.py. Anything we don't set here will be inherited from farmconfig.py. We will configure farmconfig.py later.

# -*- coding: iso-8859-1 -*-
from farmconfig import FarmConfig                                                                                               

class Config(FarmConfig):

    # This wiki config  ----------------------------------------------------------
    sitename = 'Wiki1 Site'                                                       
    page_front_page = u"FrontPage" # default wiki page to show                    
    logo_string = u''         
    theme_default = 'modern' # default theme to use for everyone                  
    interwikiname = "wiki1"                                                       

    # Data  ----------------------------------------------------------
    data_dir = '/disk01/moinmoin/wiki/wiki1/data/' # where all wiki1's pages are kept
    data_underlay_dir = '/disk01/moinmoin/wiki/underlay/' # shared help and system docs across all wikis
    user_dir = '/disk01/moinmoin/wiki/wiki1/data/user' # common user directory for all farm wikis       
    edit_locking = 'lock 10' # Page Locking types: None, 'warn ', 'lock '.  

    # Mail  ----------------------------------------------------------
    mail_from = u"Wiki1 " # name of user email comes from
    mail_smarthost = "mail.yourserver.org" # name of mail server to send mail thru    

    # Security ----------------------------------------------------------
    # login name from the wiki. Signup for an account and add the name here.
    superuser = [u"RobertJones", ]                                          
    acl_rights_before = u"RobertJones:read,write,delete,revert,admin"       
    # Users have to login to edit,delete,revert pages. Anyone can read pages.
    acl_rights_default = u'Known:read,write,delete,revert All:read'          

    DesktopEdition = False # make sure desktop edition is turned off

Now we need to edit the farmconfig.py file. This is where we will put the lines that are regular expressions that match the host headers on requests and direct them to the correct wiki's in the farm. Find the section wikis = [ ] The first entry on the line is wiki name. The second entry is the regex that matches the host header from the http request and sends the request to the wiki. One line is for the long host name and one is for the short host name. Comment out and other lines that are in there that are not being used by any other wikis. Like any default lines (current default line is called mywiki). Then save the file. Here's an example for wiki1. The first line is for the full hostname of wiki1. The second line is for the short hostname of wiki1.

    ("wiki1",  r"^wiki1.yourserver.org/.*$"),
    ("wiki1",  r"^wiki1/.*$"),

Update for MoinMoin 1.9.x: You might need to put ("wiki1", r"^http://wiki1/.*$"), instead of the above.

Make sure of all files belong to moinmoin user and group.

chown -R moinmoin: /disk01/moinmoin/

If your running/testing MoinMoin on your local machine and want to test this setup you will need to put the following type of information in your /etc/hosts file. This will allow you to use the IP address of your local machine with the wiki name you your making for your site. The example below would be for wiki1 we made above. It would be accessible at the url "http://wiki1/".

127.0.0.1 localhost wiki1

If your running the wiki and it needs to be accessed by anyone on the network then the wiki will need it's own host name put in the local DNS server. You would have to put the host name wiki1.yourserver.org in DNS. The way this setup works is one ip is chosen for all wikis. Then the primary name of the wiki is an A record just called wiki.yourserver.org. This is not used for any wiki. All other wiki's are given CNAME's (aliases) to this wiki. The following is an example from the DNS records of a BIND name server. With the A record for the site and the CNAME for the first wiki wiki1. You can keep adding CNAME's for each new wiki you make.

wiki.yourserver.org.             86400   IN      A       192.168.0.245
wiki1                            86400   IN      CNAME   wiki   

To start MoinMoin just use the moin.py script with it's options. Replace --start with --help to see other startup options. If you need to try to debug an issue start the server with the same line but leave off the --start. It will run the server in the foreground so you can see the error messages.

cd /disk01/moinmoin
MoinMoin/script/moin.py server standalone --start

Update for MoinMoin 1.9.x:There are no wiki pages by default anymore in 1.9.x. No help pages, no system pages, no template pages, etc. The language setup page now has links to install the help files. My install did not have a link to this page from the main page but you can type it in to get to it. For example: http://wiki1/LanguageSetup

Only the wiki superuser can install the the packages from the language pages. Make sure you set yourself as a superuser in the config file before doing this and restart the server. Then click the install link from the language setup page to install the packages you want. The link from that page looks like: http://wiki1/LanguageSetup?action=language_setup

Adding a new theme

Wiki's can have their own themes. You can make your own them using a current them as a template. We will make a copy of the "modern" theme in the themes directory (moinmoin/wiki/htdocs/) and we will call the new theme "theme1". The theme dir's hold CSS and images for the wiki. This example will make a them for the wiki we made above wiki1.

cp -R /disk01/moinmoin/wiki/htdocs/modern /disk01/moinmoin/wiki/htdocs/theme1

Copy the script from the modern theme MoinMoin/theme/modern.py to it's new name theme1.py in the theme1 dir.

cp -R /disk01/moinmoin/MoinMoin/theme/modern.py /disk01/moinmoin/wiki/wiki1/data/plugin/theme/theme1.py

Edit the file "theme1.py" and change at least the variable name = "modern" to the name of the theme name = "theme1". There are lots of other things you can change in this file that will make the wiki pages look different. This is the file that assembles the different parts of the pages for the theme.

Make sure of all files belong to moinmoin user and group.

chown -R moinmoin: /disk01/moinmoin/

In a self running MoinMoin you might need to restart the server to see your new theme. You should be able to see your new theme when you login and go to your setttings-> preferences under "Preferred theme". After that start editing the files in the themes directory. Choose the theme in your profile to see your changes. If you want it to be the default theme set it to be in the main config for the wiki. The themes are just CSS and images so you can change those to make the pages look different (colors,fonts,etc).

Export a wiki to static pages

The original dump script that comes with 1.8.2 (MoinMoin/script/export/dump.py) works somewhat but needs some fixes and upgrades to work well enough to do exports. The exporting of just user created pages does not work in the original dump.py even though it says it does. It dumps all help, system, and user pages. There is a patch that fixes this in the actual MoinMoin wiki but has never been merged . Also, the template that the dump.py uses is in the script itself. Another patch was offered on the official MoinMoin wiki to use external templates. I have merged both of these patches offered in the MoinMoin wiki in and made a new script called pantzwikidump.py.

Here is the diff of the dump.py script that comes with 1.8.2 with my changes. Patch your dump.py and then I will give you some examples using this script.

127a128,131                                                                                                        
>         self.parser.add_option(
>             "", "--template", dest = "template_file",                                                         
>             help = "Use a customised template instead of the built-in template"                               
>         )                                                                                                     
169a174,178                                                                                                        
>         else:                                                                                                 
>             #remove underlay and system pages from list, i.e. reduce to pure "data" pages                     
>             #pages = [pagename for pagename in pages if Page.Page(request, pagename).isStandardPage() ]
>             #remove underlay and system pages from list, i.e. reduce to pure "data" pages. Including edited underlay pages.
>             pages = [pagename for pagename in pages if not Page.Page(request, pagename).isUnderlayPage()]
208a218,232                                                                                                                     
>                                                                                                                            
>                 if self.options.template_file:                                                                             
>                     output_template = ''                                                                                   
>                 if os.path.exists(self.options.template_file):
>                     f = None                                 
>                     try:                                                                                                   
>                         f = open(self.options.template_file, 'rt')
>                         output_template = f.read()                                                                         
>                         f.close                                                                                            
>                     except IOError:                                                                                        
>                         pass                                                                                               
>                 if not output_template:                                                                                    
>                     script.log('Template file "%s" does not exist! Using built in template.' % self.options.template_file)
>                     output_template = page_template                                                                        
>                                                                                                                            
211c235                                                                                                                         
<                 fileout.write(page_template % {                                                                            
---                                                                                                                             
>                 fileout.write(output_template % {                                                                          

First is a template that can be used with the --template option. This allows you to use external template files instead of being stuck with the internal template file built into the dump.py file. You can save the template file below and call it whatever you want. It will be accessed on the command line when the dump script is run.

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=%(charset)s">
<title>%(pagename)s</title>
<link rel="stylesheet" type="text/css" media="all" charset="utf-8" href="%(theme)s/css/common.css">
<link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="%(theme)s/css/screen.css">
<link rel="stylesheet" type="text/css" media="print" charset="utf-8" href="%(theme)s/css/print.css">
<style type="text/css">
ul.pagetitle{
  display: inline;
  margin: 0;
  padding: 0;
  font-size: 1.5em;
}
li.pagetitle{
  display: inline;
  margin: 0;
}
td.noborder {
  border: 0;
}
</style>
</head>

<body>
<table>
<tr>
<td class="noborder">
<!-- %(logo_html)s -->
<img src="http://www.yourserver.org/images/logo.png" border="0" alt="Logo" style="border:none; /></a>
</td>
<td class="noborder">
<ul class="pagetitle">
<li class="pagetitle"><a class="backlink">%(pagename)s</a>
</ul>
<br><br>
<!-- %(navibar_html)s -->
</td>
</tr>
</table>
<hr>
<div id="page">
%(pagehtml)s
</div>
</body>
</html>

Here are some dump script examples of dumping wiki1 using the patched dump.py file which I will be calling pantzwikidump.py. The dump script has a few more options than below like dumping files based on user permissions. To see these options just run: MoinMoin/script/moin.py export dump --help. Just note that the moin.py file calls the dump.py script.

Dump wiki1's user created pages using the modified dump script pantzwikidump.py. Put the static files in /tmp/export (target). Use the template file /tmp/export/template.tpl.

MoinMoin/script/moin.py \
--config-dir=/disk01/wiki/moinmoin/wiki/wiki1/ \
--wiki-url=wiki1.yourserver.org/ export pantzwikidump \
--target-dir=/tmp/export/ \
--template=/tmp/export/template.tpl

Same dump for wiki named wiki1 but just dump the single wiki page WikiPage1

MoinMoin/script/moin.py \
--config-dir=/disk01/wiki/moinmoin/wiki/wiki1/ \
--wiki-url=wiki1.yourserver.org/ export pantzwikidump \
--target-dir=/tmp/export/ \
--template=/tmp/export/template.tpl \
--page=WikiPage1

By default the dump script uses whatever theme is the default theme set for the wiki. You have to copy the theme dir to the export dir (target dir) so it can read all the rss and images for the static wiki pages. For example if your them is modern then copy over the modern theme dir to your export dir.

Reddit!

Related stories


RSS Feed RSS feed logo

About


3com

3ware

alsa

alsactl

alsamixer

amd

android

apache

areca

arm

ati

auditd

awk

badblocks

bash

bind

bios

bonnie

cable

carp

cat5

cdrom

cellphone

centos

chart

chrome

chromebook

cifs

cisco

cloudera

comcast

commands

comodo

compiz-fusion

corsair

cpufreq

cpufrequtils

cpuspeed

cron

crontab

crossover

cu

cups

cvs

database

dbus

dd

dd_rescue

ddclient

debian

decimal

dhclient

dhcp

diagnostic

diskexplorer

disks

dkim

dns

dos

dovecot

drac

dsniff

dvdauthor

e-mail

echo

editor

emerald

encryption

ethernet

expect

ext3

ext4

fat32

fedora

fetchmail

fiber

filesystems

firefox

firewall

flac

flexlm

floppy

flowtools

fonts

format

freebsd

ftp

gdm

gmail

gnome

google

gpg

greasemonkey

greylisting

growisofs

grub

hacking

hadoop

harddrive

hba

hex

hfsc

html

html5

http

https

hulu

idl

ie

ilo

intel

ios

iperf

ipmi

iptables

ipv6

irix

javascript

kde

kernel

kickstart

kmail

kprinter

krecord

kubuntu

kvm

lame

ldap

linux

logfile

lp

lpq

lpr

maradns

matlab

memory

mencoder

mhdd

mkinitrd

mkisofs

moinmoin

motherboard

mouse

movemail

mplayer

multitail

mutt

myodbc

mysql

mythtv

nagios

nameserver

netflix

netflow

nginx

nic

ntfs

ntp

nvidia

odbc

openbsd

openntpd

openoffice

openssh

openssl

openvpn

opteron

parted

partimage

patch

perl

pf

pfflowd

pfsync

photorec

php

pop3

pop3s

ports

postfix

power

procmail

proftpd

proxy

pulseaudio

putty

pxe

python

qemu

r-studio

raid

recovery

redhat

router

rpc

rsync

ruby

saltstack

samba

schedule

screen

scsi

seagate

seatools

sed

sendmail

sgi

shell

siw

smtp

snort

solaris

soundcard

sox

spam

spamd

spf

spotify

sql

sqlite

squid

srs

ssh

ssh.com

ssl

su

subnet

subversion

sudo

sun

supermicro

switches

symbols

syslinux

syslog

systemd

systemrescuecd

t1

tcpip

tcpwrappers

telnet

terminal

testdisk

tftp

thttpd

thunderbird

timezone

ting

tls

tools

tr

trac

tuning

tunnel

ubuntu

unbound

vi

vpn

wget

wiki

windows

windowsxp

wireless

wpa_supplicant

x

xauth

xfree86

xfs

xinearama

xmms

youtube

zdump

zeromq

zic

zlib