Steps to setup Moin for your Apache server
==========================================

These instructions are only an example, please refer to the upstream-supplied
documentation files in this package, http://moinmo.in/ and
http://code.google.com/p/modwsgi/ for more instructions on setting up Moin and
mod_wsgi.

It's very important to read the documentation in /usr/share/doc/moin-*,
especially when upgrading to a newer version of this package! 'rpm -qd moin'
should give a list of the documentation files in this package.

Moin is a pure WSGI application since 1.9.0, this README will guide you
through a basic setup with Apache and mod_wsgi. Make sure you have the
mod_wsgi package installed from the Fedora package repository. Refer to the
Moin website for documentation about setting up Moin with FCGI/SCGI/CGI or
with other web servers such as lighttpd.

Since 1.9.0 Moin runs a server to serve the static files itself from the path
defined in the url_prefix_static variable in wikiconfig.py.

Set up a wiki instance
----------------------

First you need a wiki instance, which can be set up as follows:

#!/bin/sh
DESTDIR=/var/www/mywiki
mkdir -p $DESTDIR
chcon -t httpd_sys_content_t $DESTDIR
cp -a /usr/share/moin/{data,underlay} $DESTDIR
chown -R apache:apache $DESTDIR/{data,underlay}
chcon -R -t httpd_sys_rw_content_t $DESTDIR/{data,underlay}


Set up Moin
-----------

#!/bin/sh
DESTDIR=/var/www/mywiki
mkdir -p $DESTDIR
cp -a /usr/share/moin/server/moin.wsgi $DESTDIR
cp -a /usr/share/moin/config/wikiconfig.py $DESTDIR
chcon -t httpd_sys_content_t moin.wsgi wikiconfig.py
cat > /etc/httpd/conf.d/mywiki.conf <<EOF
# this is the URL http://servername/mywiki/ you will use later to invoke moin:
WSGIScriptAlias /mywiki "$DESTDIR/moin.wsgi"

# The WSGI socket needs to be somewhere Apache has access to
WSGISocketPrefix /var/run/moin-wsgi

# in case you want your wiki under the root url (http://servername/), use this instead:
#Alias /robots.txt $DESTDIR/htdocs/robots.txt
#Alias /favicon.ico $DESTDIR/htdocs/favicon.ico
#WSGIScriptAlias / $DESTDIR/moin.wsgi

# create some wsgi daemons:
WSGIDaemonProcess moin user=apache group=apache home=$DESTDIR \
	processes=5 threads=10 maximum-requests=1000 umask=0007 \
	display-name=wsgi-moin

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

# This is required if you plan to use HTTP authorization. Without it the user name won't
# be passed to MoinMoin.
#WSGIPassAuthorization On
EOF

The moin.wsgi file adds $DESTDIR to the Python search path, so Python should be
able to find wikiconfig.py automatically. The wikiconfig.py should be edited
according to your needs.
Finally, restart Apache by doing a "service httpd restart".


Configuring Moin with FastCGI
=============================

This approach requires mod_fcgid:
http://httpd.apache.org/mod_fcgid/

It is necessary to turn on the SELInux httpd_enable_cgi boolean to run either
regular or FastCGI scripts:

   setsebool -P httpd_enable_cgi 1

Setting up moin with mod_fcgid is very similar to setting it up with mod_wsgi.
First, set up a wiki instance as before:

#!/bin/sh
DESTDIR=/var/www/mywiki
mkdir -p $DESTDIR
chcon -t httpd_sys_content_t $DESTDIR
cp -a /usr/share/moin/{data,underlay} $DESTDIR
chown -R apache:apache $DESTDIR/{data,underlay}
chcon -R -t httpd_sys_rw_content_t $DESTDIR/{data,underlay}

Then, to set up moin:

#!/bin/sh
DESTDIR=/var/www/mywiki
mkdir -p $DESTDIR/cgi-bin
cp -a /usr/share/moin/server/moin.fcg $DESTDIR/cgi-bin
cp -a /usr/share/moin/config/wikiconfig.py $DESTDIR/cgi-bin
chcon -R -t httpd_sys_script_exec_t $DESTDIR/cgi-bin
cat > /etc/httpd/conf.d/mywiki.conf <<EOF
# Wiki application data common to all wiki instances
Alias /moin_static193 "/usr/lib/python2.7/site-packages/MoinMoin/web/static/htdocs/"
<Directory "/usr/lib/python2.7/site-packages/MoinMoin/web/static/htdocs/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault "access plus 1 year"
    </IfModule>
</Directory>
# Wiki instance with mod_fcgid
<IfModule mod_fcgid.c>
    ScriptAlias /mywiki "$DESTDIR/cgi-bin/moin.fcg"
    <Directory "$DESTDIR/cgi-bin/"
        Options Indexes FollowSymLinks ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</IfModule>
EOF

Note that the URL is moin-version specific (the example is for moin 1.9.3)
and python version specific (the example is for python 2.7) and will need
to be tweaked accordingly.

Edit $DESTDIR/cgi-bin/wikiconfig.py to suit your needs and then restart the
web server to load the new configuration:

   service httpd restart


Upgrading from previous versions
================================

See README.migration for full details. You will need to run one or more
migration scripts.

To upgrade from a pre-1.5.3 version, or from a wiki created using moin 1.5.3,
you will need to run one or more "old-style" migration scripts, ending with
152_to_1050300.py. This is done as follows:

# cd /var/www/mywiki
(substitute the actual location of your wiki instance for /var/www/mywiki)

# runuser -s /bin/sh -c "python /usr/lib/python2.*/site-packages/MoinMoin/script/old/migration/152_to_1050300.py" apache
(use the same approach to run any migration scripts, in order, as indicated in
README.migration; 152_to_1050300.py should be the *last* one)

For a wiki previously updated to 1.5.3, or created in 1.5.4 or later, only one
migration script needs to be run:

# runuser -s /bin/sh -c "moin --config-dir=/var/www/mywiki/cgi-bin --wiki-url=www.example.com/mywiki/ migration data" apache
(substitute the actual location of your wiki configuration directory for
/var/www/mywiki/cgi-bin, and your wiki's URL [minus the protocol part] for
www.example.com/mywiki/)