MoinMoin Installation on Fedora

This HowTo is a practical guide about installing MoinMoin wiki on Fedora 19.
MoinMoin versions
  • 1.9.7, possibly others
Requirements
  • Fedora 19
  • Apache 2.4
  • mod_wsgi (optional)
DISCLAIMER - THERE IS NO WARRANTY OF ANY KIND.
This HowTo has been written with the purpose to help system administrators to test MoinMoin wiki. I don't claim that the configuration described here is safe, or adequate from a security point of view for production environments. Please review your security rules carefully before applying them.

Installation

You can install MoinMoin using yum package manager or directly from sources.

To use the package manager, run the following command as root user:

# yum install moin

To install from sources, first you need to download the software:

$ wget http://static.moinmo.in/files/moin-1.9.7.tar.gz

then check the integrity of the downloaded file, you can find the MD5 checksum on MoinMoin:MoinMoinDownload

$ md5sum moin-1.9.7.tar.gz

Uncompress the tarball in a convenient location and install it:

$ tar xzvf moin-1.9.7.tar.gz
$ cd moin-1.9.7/
$ sudo python setup.py install --force --record=install.log --prefix='/usr/local'

Keep install.log for future reference, it can be useful to determine which file were installed in case we need to uninstall MoinMoin.

Create a Wiki Instance

It is important that you understand the different locations used in a MoinMoin setup, so read this carefully.

In the following descriptions, PREFIX is what you used with during the setup.py command. If you installed using yum package manager PREFIX is equal to /usr.

Look into install.log to find out about following important locations:

  • MoinMoin directory, PREFIX/lib/pythonX.Y/site-packages/MoinMoin this is where the MoinMoin source code is located
    • htdocs PREFIX/lib/pythonX.Y/site-packages/MoinMoin/web/static/htdocs this is where the directory with html support files (images for the various themes, etc.) - the web server will need to access this
  • share directory, PREFIX/share/moin this is where the templates are located
    • config - MoinMoin example configuration files (like wikiconfig.py)
    • data directory (wiki pages, users, etc.) - only MoinMoin should access this
    • server - MoinMoin startup files (for CGI, WSGI and other files for other startup methods)
    • underlay directory (system pages) - only MoinMoin should access this

We talk of templates in the share directory because you usually will not use those files at that location, but copy them elsewhere when you need them. This way, you can set-up several wikis without problems, and easily upgrade to new MoinMoin versions.

After you have downloaded and installed MoinMoin, you will want to "have a wiki", so you have to copy several directories and files. This way, you can have as many wikis as you want, and you can easily upgrade MoinMoin only the original files will be overwritten, not your copies.

Every time you copy those files (and modify the configuration of your server accordingly), you create what is called a wiki instance. Each wiki instance is independent from the others, with a different configuration, different pages, different users, etc.

Directory Structure

We create a wiki instance under /srv/www/moin, this is the directory structure:

/srv/www/moin                   # Wiki Root
/srv/www/moin/config            # Config Files
/srv/www/moin/data              # Data Files
/srv/www/moin/log               # Log Files
/srv/www/moin/server            # CGI and WSGI scripts
/srv/www/moin/static            # Static Files for Themes
/srv/www/moin/underlay          # System Pages and Files

Login as root user and copy the files

# cd /srv/www/
# mkdir moin moin/log
# cp -R /usr/share/moin/config moin
# cp -R /usr/share/moin/data moin
# cp -R /usr/share/moin/server moin
# cp -R /usr/share/moin/underlay moin
# cp -avi /usr/lib/python2.7/site-packages/MoinMoin/web/static/htdocs static
NOTE
As this is a test installation we copied everything, but on a production server it is better to be more restrictive and copy only the scripts and configuration files needed.

Setting Permissions

We need to restrict the permissions of the wiki instance, so that only the web server can read and write them.

# chown -R apache.apache moin   # Check USER.GROUP in httpd.conf
# chmod -R ug+rwX moin          # USER.GROUP may read and write
# chmod -R o-rwx moin           # everybody else is rejected

SELinux File Contexts

With the directory structure above, set the file contexts as follows:

# semanage fcontext -a -t httpd_sys_rw_content_t "/srv/www/moin/config(/.*)?"
# semanage fcontext -a -t httpd_sys_content_t "/srv/www/moin/config/logging(/.*)?"
# semanage fcontext -a -t httpd_sys_content_t "/srv/www/moin/config/.*\.py"
# semanage fcontext -a -t httpd_sys_rw_content_t "/srv/www/moin/data(/.*)?"
# semanage fcontext -a -t httpd_sys_content_t "/srv/www/moin/data/plugin(/.*)*/.*\.py"
# semanage fcontext -a -t httpd_log_t "/srv/www/moin/log(/.*)?"
# semanage fcontext -a -t httpd_sys_script_exec_t "/srv/www/moin/server(/.*)?"
# semanage fcontext -a -t httpd_sys_content_t "/srv/www/moin/static(/.*)?"
# semanage fcontext -a -t httpd_sys_rw_content_t "/srv/www/moin/underlay(/.*)?"

For more details about MoinMoin and SELinux contexts see MoinMoin:HowTo/FedoraSELinux.

Run restorecon to apply these contexts on all affected files:

# restorecon -vr /srv/www/moin

It's good advice to run restorecon with the -n option first to check what changes would be applied.

Configure MoinMoin

Edit the file /srv/www/moin/wikiconfig.py to configure MoinMoin wiki.

This file is thoroughly commented, here we make sure to use absolute paths. This way we ensure that the needed files are definitely found and save ourself some troubles.

The essential configuration directives are:

# vi /srv/www/moin/wikiconfig.py
...
instance_dir = /srv/www/moin
data_dir = /srv/www/moin/data
data_underlay_dir = /srv/www/moin/underlay
url_prefix_static = '/moin_static'
sitename = u'MyWiki'
...

The url_prefix_static is used to access the static files used for the website theme. Later on we will create an alias in the Apache configuration that point to our static directory /srv/www/moin/static.

Configure WSGI / CGI

MoinMoin is a WSGI application, so we can use Apache with mod_wsgi, which is very fast and the recommended deployment.

Also we can use others legacy deployment methods for serving MoinMoin from non-WSGI-aware setups. The needed adapters can be found inside /srv/www/moin/server directory.

  • CGI: the classic protocol for web application serving, it's slow but works almost everywhere.
  • FastCGI / SCGI / AJP: fast, and in the case of FastCGI, quite widespread.

For this to work we need to make MoinMoin and Python find all the needed files. Add the correct locations to moin.cgi or moin.wsgi file.

# vi /srv/www/moin/server/moin.cgi
...
sys.path.insert(0, '/usr/lib/python2.7/site-packages')
sys.path.insert(0, '/srv/www/moin/config')
...

Configure Apache

Apache + CGI

For our test environment we are going to use CGI.

To enable Apache to serve MoinMoin wiki pages we need to create the moin.conf file under etc/httpd/conf.d directory, here its content:

#
# MoinMoin CGI configuration
#
Alias /moin_static /srv/www/moin/static
ScriptAlias /moin /srv/www/moin/server/moin.cgi
<Directory "/srv/www/moin">
    AllowOverride All
    Require all granted
</Directory>
NOTE
This configuration file works for Apache 2.4. If you are using Apache 2.2, you may want to upgrade to version 2.4, but keep in mind that there have been significant changes in authorization configuration, and other minor configuration changes, that could require changes to your 2.2 configuration files before using them for 2.4. See `Apache Upgrading to 2.4 from 2.2`_

Example for Apache 2.2 can be found at http://wiki.apache.org/httpd/MoinMoin/InstallDocs.

Apache + WSGI

WSGI is the recommended deployment, to use it you need to activate EPEL repository and install mod_wsgi package:

# yum install mod_wsgi

Then create the moin.conf file under etc/httpd/conf.d directory, like this:

#
# MoinMoin WSGI configuration
#
Alias /moin_static /srv/www/moin/static
#
# you will invoke your moin wiki at the root url, like http://servername/FrontPage:
WSGIScriptAlias /moin /srv/www/moin/server/moin.wsgi
#
# create some wsgi daemons - use user/group same as your data_dir:
WSGIDaemonProcess moin user=apache group=apache processes=5 threads=10 maximum-requests=1000 umask=0007
#
# use the daemons we defined above to process requests!
WSGIProcessGroup moin
#
# WSGISocketPrefix
WSGISocketPrefix /var/run/moin-wsgi
CAUTION
WSGI_ configuration has not been tested for this setup.

Test Your Wiki Instance

Restart Apache server:

# service httpd restart

Now point your browser at http://localhost/moin, you should be able to use MoinMoin wiki.

Danilo

References: