moinmoin Installation/Setup

Version 1.9.x (Ubuntu, Apache2, WSGI, standalone)

In order to make an installation/setup easier, I like to document it by step by step command lines. This has the advantage to use copy and paste with the terminal.

Update 2018-04-03, wiki Version 1.9.9.

In case of editing add new lines below the originals and comment out the old once.

$ cp /home/pi/Downloads/moin-1.9.9.tar.gz /home/pi
$ cd /home/pi
$ tar xzf moin-1.9.9.tar.gz
$ sudo chown -R www-data:www-data moin-1.9.9
$ sudo chmod -R g+w moin-1.9.9
$ cd moin-1.9.9
$ touch moin-1.9.9.txt  # show version number in folder

# check for user in group www-data
$ groups

# if www-data is not included in the list, add user to it
$ sudo adduser pi www-data

Moin WSGI setup for Apache2 web server

$ cp wiki/server/moin.wsgi .
$ gedit moin.wsgi
- add: sys.path.insert(0, '/home/pi/moin-1.9.9')
- add: from MoinMoin import log
- add: log.load_config('/home/pi/moin-1.9.9/wikiserverlogging.conf')
save file

Do first the modification, before activating the new wiki. Otherwise, latest after 5 minutes you will have some spam accounts set.

If after an apache2 restart the wiki page does not show CSS formatting,
look in file /etc/apache2/httpd.conf if Alias /moin_static197 is set wrong.

If after an apache2 restart the wiki pages does look OK, but after editing and saving a traceback is thrown, have a look for the permissions. Im my case the folder moin-1.9.9 should have user:group of www-data:www-data, the user folder must have the user:group permission of the user.


$ mv
$ cp wiki/config/ .
$ sudo chown -R www-data:www-data * 
$ gedit
- add: sitename = u'rudiswiki9'
- add: instance_dir = os.path.join(wikiconfig_dir, 'wiki') 
just for customising
- add: logo_string = u'<img src="%s/common/Asus900A_RudisWiki_baby_re.png" alt="RudisWiki Logo">' % url_prefix_static 
- add:     page_front_page = u"Frontpage"
- add:     interwikiname = u'rudiswiki9'
- add:     show_interwiki = 1
- add:     superuser = [u'RudolfReuter', ]
- add:     acl_rights_before = u'RudolfReuter:read,write,delete,revert,admin All:read'
- add:     mail_smarthost = ""
- add:     mail_from = u"RudolfReuter <>"
- add:     mail_login = "reuterxx xxxxxxxx"  # user password
- add:     language_default = 'de'
save file

Cloning moin for backup

In order to clone moin for backup purpose you have to make several changes after copying to a new folder.

# First copy folder
$ cp -r moin-1.9.6 moin-1.9.9

# Edit moin-1.9.9/moin.wsgi 2x
sys.path.insert(0, '/home/pi/moin-1.9.9')

# Edit wikiserverlogging.conf 1x

# Edit /etc/apache2/httpd.conf 7x,  with sudo 
#Alias /moin_static196 /home/pi/moin-1.9.9/MoinMoin/web/static/htdocs/
<Directory /home/pi/moin-1.9.9/MoinMoin/web/static/htdocs>
WSGIScriptAlias /wiki /home/pi/moin-1.9.9/moin.wsgi
WSGIDaemonProcess moin_196b user=www-data group=www-data processes=1 threads=4 maximum-requests=100 umask=0007
WSGIProcessGroup moin_196b
<Directory /home/pi/moin-1.9.9>

# clear cache
$ moin-1.9.9/ maint cleancache

# correct user:group
$ sudo chown -R www-data:www-data moin-1.9.9

# get into use
$ sudo service apache2 restart

# adopt index page

Setup logging for rotating log file

In case of the "Desktop Edition" it is the easiest method to do the logging on the error output, in a console window.
If you want to setup "moin" in the server mode (run as background daemon) the logging must be done to a file. Especially in an embedded environment you do not have the full support of Linux. So, a rotating log file handler (python standard) is welcome.

# This is the standalone wikiserver logging configuration.
# It can be easily modified to help when debugging, see the comments.
# Available loglevels, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
# 2014-04-08 RudolfReuter, adopted to RotatingFileHandler




# adapt the next lines to your debugging needs:


args=('%(logfile)s', 'at')

# after test, switch from DEBUG to INFO
#args=(sys.stderr, )
# rotate if the size of 64000 bytes are reached, 3 files total.
# args  filename, mode, maxBytes, backupCount
args=('%(logfile)s', 'a', 64000, 2)


format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s

# Server run daemon:
$ cp MoinMoin/sript/ .   # copy run daemon to main folder
$ chmod 755 moin                # set execute bits

#from MoinMoin import log
from MoinMoin import log

Apache2 setup

$ sudo /etc/init.d/apache2 restart

Setup moin as web Standalone Server

In order to run moin as a web standalone server for testing, you have to do the following setup on file

hostname = ''
port = 8080
user = 'www-data'
group = 'www-data'

Start web server for test:
$ ./

Point web browser to main web page:

In order to boot the moin standalone web server automatic create the file /etc/init.d/

File: /etc/init.d/

# Provides:          moin_sas
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2
# Default-Stop:      
# Short-Description: Start moin wiki as StandAlone Server (_sas).
# Description:       adopt PYTHONPATH, PREFIX
# Structur Reference:
# Debug with: sh -x (linewise output with '+' Prefix)
# Port check with: nmap localhost
# for DockStar, NSLU2, SlugOS/BE, RAM-disk
# Start with "root", runs under "user" (setup in for better security
# file must be stored in /etc/init.d
# Install file with: cd /etc/init.d; update-rc.d default
# 2010-12-11 RudolfReuter
# 2013-04-11 RudolfReuter, start with moin command

if [ -d "/var/volatile" ]; then
    # create new RAM-disk directory
    # if not exist, create directory for user
    # no permission for user, if no execute bit! 
    if [ ! -d "$RAMDISK" ]; then
        mkdir -m 755 "$RAMDISK" 2>&1 | logger
        chown pi:pi "$RAMDISK"

# check for existing python
if [ ! -e "$PYTHONPATH" ]; then
  echo " Error - NO $PYTHONPATH" | logger

PREFIX="/home/pi/moin-1.9.9"  # moin home folder
PARAMS=" server standalone --user=www-data --group=www-data"

if [ ! -x "$MOINPATH" ]; then
  echo " Error - No file moin, or no exec attr. 775" | logger

# check for first letter of LINK in /etc/rc2.d and set START/STOP
if [ -z "$1" ] ; then
    case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in
        S??*) rc="start" ;;
        K??*) rc="stop" ;;
        *) rc="usage" ;;

case "$rc" in
        echo "Starting web server: $DAEMON" 2>&1 | logger
        cd $PREFIX
        $MOINPATH $PARAMS --start 2>&1 | logger
        # change owner, otherwise it cannot be deleted at Stop
        if [ -e "" ] ; then
            chown www-data:www-data
        echo "Stopping web server: $NAME" 2>&1 | logger
        cd $PREFIX
        $MOINPATH $PARAMS --stop 2>&1 | logger
        "$0" stop
        sleep 1
        "$0" start
        echo "Usage: $0 (start|stop|restart)"
        exit 3
exit 0
# end of file

and install it with:

$ sudo update-rc.d defaults

the startup link "/etc/rc2.d/" will be created.

For more information to the init system type: man update-rc.d, or man init

Additional server help file moin must be copied to the home directory and extended:

$ cd /home/pi/moin
$ cp wiki/server/moin moin

Add the following lines before "run()" to change the logging config:

from MoinMoin import log

Now the moin daemon can be started manually for testing:

$ sudo /etc/init.d/ start

Check with process dir:
$ ps -Af
www-data  8861 1 0 13:46 ? 00:00:06 python /home/pi/moin-1.9.9/moin server standalone --user=www-data --group=www-data --start

# in the logging file moin_rot.log the last 4 lines should be:
date INFO MoinMoin.log:135 using logging configuration read from "/home/pi/moin-1.9.9/wikiserverlogging.conf"
date INFO MoinMoin.log:157 Running MoinMoin 1.9.9 release code from /home/pi/moin-1.9.9/MoinMoin
date INFO MoinMoin.web.serving:129 Running as uid/gid 33/33
date INFO werkzeug:116  * Running on http://localhost:8080/

# If it does not work, you can trace the startup file:
$ sudo bash -x /etc/init.d/ start

After a reboot the moin standalone server should now start automatically.

moin security fixes

On this web page you can find the security fixes for moin.

The installation is also described. What was missing was a detailed patch procedure. So, I will try to explain it more detailed, in order to make it more easy to apply the patches. Therefore I will use a security fix of moin 1.9.5 as an example.

$ patch --verbose --dry-run  -b -p1 < m195_security_fix1.diff

# explanation of the options
  --verbose  # tell me more
  --dry-run  # just test the patch
  -b         # make a backup of the original file
  -p1        # reduce one level of the path in the diff file (a/)

$ patch --verbose  -b -p1 < m195_security_fix1.diff

Setup for interwiki Sync

Because I had a lot of problems with interwiki sync, I switched to utility rsync, and call rsync to sync the whole path wiki/data/pages.

Delete all synctags at once

In case of manual copying pages between servers, or synching with multiple servers, it is necessary to delete before synching the synctags in the page folder. This can be done for all pages from the command line:

$ cd wiki

$ find . -name synctags -exec rm {} \;

Moin Update / Setup

When you update the moin wiki software, you basically install a new version, and set it up to your specific needs.

In the next step you copy all your old data pages to the new wiki, and restart it (touch moin.wsgi).

When all was setup correct, you navigate to the new wiki address. What do you see: Not very much, a logo and a menu bar. The next steps are:

If it is not your fist wiki, instead an update, copy the old pages (version 1.9.x) from wiki/data/pages/ to the new installation.

In order to not limiting the TableOfContent width to 50% line length, I increased this value to 90% in MoinMoin/web/static/htdocs/modern/css/common.css about line 139. This will reduce the number of line breaks in the table of contents.

Highlight Lexer

In order to displaying a table with the list of available Pygments lexers, you need HighlighterList macro. To install:

GraphViz Support

In order to install the moin support for Graphviz you have to install from the archiv [[|]:

$ unzip
# to wiki/data/plugin/action/
# to wiki/data/plugin/parser/
$ cp -r MoinGraphViz-1.0rc4-brn-1.9.x.comp/wiki ~/moin-1.9.9/wiki/
$ cp -r MoinGraphViz-1.0rc4-brn-1.9.x.comp/umoin ~/moin-1.9.9/MoinMoin/support/

newaccount, superuser only

To block spammers, it is neccessary to not allow everybody to create a new user:
In order to avoid SPAM creating new accounts, patch MoinMoin/action/
$ diff -c
***   2012-02-07 22:36:47.000000000 +0100
---   2012-03-13 06:53:02.000000000 +0100
*** 167,172 ****
--- 167,176 ----
      page = Page(request, pagename)
      _ = request.getText
+     # 2011-08-20 RR
+     if not request.user.isSuperUser():
+         request.theme.add_msg(_('You are not allowed to use this action.'), "error")
+         return page.send_page()
      form = request.form
      submitted = form.has_key('create')

Now only the superuser can create a new account with URL:

Contact Email page

For the Contact Email function you need the MoinComments Macro. To install it:

Then you title your macro AddComment with Contact Email and subscribe the page. Text to insert into the page:

=== Contact Email ===

When the user clicks on Send comment, the subscriber of the page will get the comment message as an Email.

Beware, when you test that function, you have to log out before you send, otherwise no Email will be send, because a notification Email is not send to the owner of the page.

Contact Email reCAPTCHA

/!\ 2017-11-04, Google wanted to change reCaptcha from version 1 to version 2. Fortunately Helder made the change on Fortunately the old keys could still be used. But I needed to remove the "logged-in users only" limitation.

Line 300: if self.can_create: 
# changed by:

Unfortunately a spammer misused my Contact Email function. Fortunately the author of package moin-comments-0.2 has provided access to the reCAPTCHA function (version 1) of Google. On that page you click on the intro link. In order to use that function, you must have an Google Email account. Next step is to sign up for an API key pair for your site. The key pair consists of a site key (public key) and secret (private key).

MoinMoin Configuration

In the configuration file you must set the parameters:

# append to file
    # 2015-12-29 use reCAPTCHA from google, because of spammer
    comment_recaptcha = True
    comment_recaptcha_public_key = "6LfDBxQTAAAAAJfBLwv......................."
    comment_recaptcha_private_key = "6LfDBxQTAAAAACn5q........................"
    comment_recaptcha_use_ssl = True

Next you must download the reCAPTCHA client library (for python) and copy it in the main folder of MoinMoin (usually moin-1.9.9/) under the name There exists also an install package for download, but I could not get it to work. It installs a module named, but the software moin-comments-0.2 did not work with that module.

With all that setup, the next step is to restart the wiki. If you have a wsgi connection to the web server apache2, you can do it with:

$ cd moin-1.9.9
$ touch moin.wsgi

When you navigate to a wiki page with the macro AddComment,

Comment this page
Are you human?
you will see now below the comment filed the reCAPTCHA for human input. Enter the shown text and click on button Send comment to send the comment to the administrator of the wiki.

/!\ When you access your web server via the inhouse IP address then reCaptcha will not work (an internal error occurred: xxx), because the domain has changed.

Screen Width Limit

In order to have a more consistent layout on different screen width, I limited the screen width in the CSS to 1000 pixel. This can be edit on line. After a reload of the web page the effect is visible.

Path MoinMoin/web/static/htdocs/modern/css/screen.css
Edit to:
body {
    padding: 0;
    border: 0;
    width: 1000px;

Moin Logo Graphic

The moin logo should show, on which computer it is installed.

The logo is drawn with Gimp. For example the logo for the Dockstar heating temperature measurement:

Count wiki pages

If you want to know how many personal pages your wiki has (including the deleted ones), use the command line:

$ ls -l moin-1.9.6/wiki/data/pages | wc -l

If you use the macro <<PageCount(exists)>> you will also get in addition the underlay pages as well.

Compare directories

You can compare directories with the standard diff command, see:

$ diff moin-1.9.8/wiki/data/pages moin-1.9.9/wiki/data/pages

List of pages in this Category:

-- RudolfReuter 2010-12-29 20:30:21

Go back to CategoryMoinMaintenance or FrontPage ; KontaktEmail (ContactEmail)

MoinSetup (last edited 2018-04-03 17:25:31 by RudolfReuter)