<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>MoinMoin/InstallDocs</title></articleinfo><para>This HTML page contains the basic install docs that can be found on <ulink url="http://master.moinmo.in/MoinMoin/InstallDocs"/>. It contains all necessary information to get your wiki up and running, even without being online. If you have a permanent internet connection, you might want to browse the docs on the HelpOnInstalling page, which might contain more up-to-date information. </para><para>After following the procedures on this page, you should have a working wiki and can browse the rest of the online docs there. </para><section><title>How to install your own MoinMoin Wiki</title><para>This page describes the installation procedure of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink>. In the next section, there is a list of real-world <link linkend="installscenarios">Installation Scenarios</link> that help you to understand how to apply the instructions in different environments. If you already have a wiki running and want to upgrade, see <ulink url="http://moinmaster.wikiwikiweb.de/HelpOnUpdating#">HelpOnUpdating</ulink>. </para><para>A MoinMoin installation is done by some elementary steps: </para><itemizedlist><listitem><para><link linkend="basic-install">Basic Installation</link> explains the &quot;<code>setup.py</code>&quot; step of the installation in more detail. This is used to get the MoinMoin code and wiki template installed onto your system. This applies equally to all scenarios, and you should read it before trying a live installation. </para></listitem><listitem><para><link linkend="wikiinstance-creation">Wiki Instance Creation</link> explains how you make a new wiki instance (data and configuration), this is also common to all scenarios. </para></listitem><listitem><para>Getting the web server to serve static stuff under the <code>url_prefix_static</code> URL - used for theme CSS and images, etc. - this is slightly different for the various web servers that can be used - see below. </para></listitem><listitem><para>Getting the web server to execute the moin code when you access wiki pages. This is done either by CGI, FastCGI, mod_python or Twisted or the built-in stand alone server - this is slightly different for the various web servers that can be used - see below. </para></listitem><listitem><para>After a successful installation, you might want to read more about configuration and other options that you, as the wiki administrator, can set up. <ulink url="http://moinmaster.wikiwikiweb.de/HelpOnAdministration#">HelpOnAdministration</ulink> contains links to pages that cover these topics. Especially, the <ulink url="http://moinmaster.wikiwikiweb.de/HelpOnConfiguration#">HelpOnConfiguration</ulink> and <ulink url="http://moinmaster.wikiwikiweb.de/HelpOnUpdating#">HelpOnUpdating</ulink> pages provide additional information regarding wiki setup and maintenance. </para></listitem><listitem><para><link linkend="trouble-shooting">Trouble-shooting</link> helps with fixing any general problems you might encounter, which apply to any installation platform.  </para></listitem></itemizedlist><para><anchor id="installscenarios"/> </para></section><section><title>Installation steps specific for some web servers and operating systems</title><para>The following links will show you concrete examples of installation sessions, showing the commands used and explaining what they do. You <emphasis>must first read the general information on installing above</emphasis> before doing the installation steps described on the pages linked from below: </para><para>Linux: </para><itemizedlist><listitem><para><link linkend="linuxapache-install">Linux Installation using Apache</link> </para></listitem><listitem><para><link linkend="linuxstandalone-install">Linux Installation using standalone server</link> </para></listitem></itemizedlist><para>Long-Running-Process Setup: </para><itemizedlist><listitem><para><link linkend="fastcgi-install">FastCGI Setup using Apache or Lighttpd</link> </para></listitem><listitem><para><link linkend="modpy-install">mod_python Setup using Apache</link> </para></listitem><listitem><para><link linkend="twisted-install">Setup using twisted</link> </para></listitem></itemizedlist><para>Mac OS X: </para><itemizedlist><listitem><para><link linkend="macosx-install">Mac OS X Installation using Apache</link> </para></listitem></itemizedlist><para>Windows: </para><itemizedlist><listitem><para><link linkend="win32apache-install">Windows Installation using Apache</link> </para></listitem><listitem><para><link linkend="win32iis-install">Windows Installation using IIS</link> </para></listitem></itemizedlist><para><anchor id="basic-install"/> </para><para><emphasis role="strong">How to do a basic installation of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> on your system.</emphasis> </para><para><emphasis role="strong">Contents</emphasis> <!--The macro TableOfContents doesn't work with the DocBook formatter.--> </para><para>Before you can integrate MoinMoin into your web environment, you have to install the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> source code and data files using the standard Python <emphasis>distutils</emphasis> mechanism (<code>setup.py</code>). This page explains the steps you usually need to take to do this. For more details on the <emphasis>distutils</emphasis> installation process, consult the <ulink url="http://www.python.org/doc/current/inst/inst.html">Installing Python Modules</ulink> document in your Python documentation set. </para><para>The installation is similar on Windows and Linux (and other POSIX-type systems; for simplicity, we just say &quot;Linux&quot; in the docs). </para><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/idea.png" width="16"/></imageobject><textobject><phrase>(!)</phrase></textobject></inlinemediaobject> We use text such as <emphasis role="strong"><code>&gt; command arguments</code></emphasis> to show what you have to type at the command prompt (also known as shell, terminal, etc.). In our examples &quot;<code>&gt; </code>&quot; is the prompt, you don't have to type it in, you have to type what comes after it. Lines that do not begin with &quot;<code>&gt; </code>&quot; are the answers to the commands you have typed. Read them carefully. </para></listitem></itemizedlist><section><title>Check if Python is working</title><para>MoinMoin needs Python to run, so the first step is to check if an usable version of Python is installed and correctly set-up. If this is not the case, you will have to fix that before you can proceed. </para><para>The <code>CHANGES</code> file in the MoinMoin archive mentions what versions are supported. Python 2.3 is the minimum requirement for MoinMoin 1.7, but we suggest you use the latest Python release version. </para><para>You can download Python at <ulink url="http://www.python.org/download/"/>. </para><para>If you are pretty sure an acceptable version of Python is installed but the commands below do not work, this may be because your Python files are not in the <emphasis>search path</emphasis>. Correctly setting the search path is outside the scope of this document; please ask for help on your favorite Python, Linux, or Windows discussion board. </para><para>If you have shell access, checking if Python is working is very simple. Just type the following command, and look at the result: </para><screen><![CDATA[> python -V
Python 2.4.4]]></screen><para>If you don't have shell access, you can try using this <code>pythontest.cgi</code> script (it assumes that you are using a Linux kind of webserver). Upload the script to your <code>cgi-bin</code> directory, use <code>chmod a+rx pythontest.cgi</code> (or a similar command in your FTP program) to make it executable, and invoke it using your web browser. </para><para><!--transclusion is not implemented in DocBook formatter-->pythontest.cgi<!--transclusion is not implemented in DocBook formatter--> </para><para>If it doesn't display &quot;CGI scripts work&quot;, well, then CGI scripts don't work. If it doesn't show one or more Python version numbers, then Python is not correctly installed. In both cases, before you can proceed, you will have to get in touch with the administrator of the server so that the problems get corrected. </para><para>Also be sure to read <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnLinuxFtp#">../ApacheOnLinuxFtp</ulink> after you've completed the ../BasicInstallation illustrated here. </para></section><section><title>Download MoinMoin</title><para>To download the distribution archive, go to the <ulink url="http://moinmo.in/MoinMoinDownload">download page</ulink> and fetch the latest archive. </para><para>The next step is to unpack the distribution archive (which you have done already if you are reading this text from your hard drive). If you read this on the web, the distribution comes in a versioned <code>.tar.gz</code> archive, which you can unpack as shown below. </para><itemizedlist><listitem><para>On Windows </para><itemizedlist><listitem><para>You can use recent versions of programs like <ulink url="http://www.7-zip.org/">7-Zip</ulink>, WinZip, WinRar, and WinAce, which handle .tar.gz kind of archives. </para></listitem><listitem><para>At the command prompt, you can use <ulink url="http://gnuwin32.sourceforge.net/packages/gzip.htm">GNU gzip</ulink> and <ulink url="http://gnuwin32.sourceforge.net/packages/tar.htm">GNU tar</ulink> for Windows. </para></listitem></itemizedlist></listitem><listitem><para>On Linux </para><itemizedlist><listitem><para>You can use your favorite file manager -- it should be able to unpack them. </para></listitem><listitem><para>At any shell prompt, you can use the <code>tar</code> command. </para></listitem></itemizedlist></listitem></itemizedlist><para>The distribution archive will always unpack into a directory named <code>moin-&lt;version&gt;</code>, for example <code>moin-1.7.0</code>. </para><para>Here is how you would unpack the archive (using GNU tar) and enter the directory with the MoinMoin files: </para><screen><![CDATA[> tar xzf moin-1.7.0.tar.gz
> cd moin-1.7.0]]></screen></section><section><title>Install MoinMoin</title><para>You can install MoinMoin to either: </para><itemizedlist><listitem><para>a system location (if you have the necessary rights to do that -- on Linux you need to be root) </para></listitem><listitem><para>some specific location, like your home directory (Linux) or <code>C:\moin</code> (Windows). </para></listitem></itemizedlist><para>The installation to a system location is easier, so choose that if possible. </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> If you have several versions of Python installed, please use the same version for setup and for running the wiki. Usually, the latest Python version will get the best results. </para><section><title>Recommended installation command for Linux (and MacOs X)</title><para>As you have chosen to not use a preconfigured package for your system this time it is highly recommended that you do not install <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> into the default location. This is because otherwise, if you later want to install a moin package of your distribution this will overwrite your existing installation. The most common path for your own installations is below <code>/usr/local</code> (this is called the PREFIX). A command that should be ok for most Linux distributions and also MacOS X is </para><screen><![CDATA[> python setup.py install --prefix='/usr/local' --record=install.log]]></screen><para>This will install the shared files to '/usr/local/share/moin' and the moin code to <code>/usr/local/lib/python2.x/site-packages/MoinMoin/</code>. </para></section><section><title>Debugging setup process</title><para>If you have problems with the <code>setup.py</code> install step, try using the command: </para><screen><![CDATA[> python -v setup.py --quiet install --record=install.log]]></screen><para>The additional <code>-v</code> flag should provide you detailed verbose messages every step of the way. </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> On Linux, if you get an error like <code>Invalid Python installation: cannot find /usr/lib/Python2.x/config/Makefile</code>, you may not have the python module <emphasis role="strong"><code>distutils</code></emphasis> installed, it's usually a part of the <emphasis role="strong">Python development libarary (<code>python-dev</code>)</emphasis>. Some Linux distributions may not have installed it by default. For example, on Mandrake you need to install the <emphasis role="strong"><code>python-devel</code></emphasis> package, on Debian it's called <emphasis role="strong"><code>python-dev</code></emphasis>. </para></section><section><title>Installing to the default system location</title><screen><![CDATA[> python setup.py --quiet install --record=install.log]]></screen><para>This installs MoinMoin to the default system location (typically the Python directory, for example on Linux, inside <code>/usr/lib/python2.x/site-packages/MoinMoin</code> and <code>/usr/share/moin</code>). Look at the <code>install.log</code> file to see what was installed, and where. </para></section><section><title>Installing in the home directory or another specific location</title><para>Linux example, installing in the home directory: </para><screen><![CDATA[> python setup.py --quiet install --prefix=$HOME --record=install.log]]></screen><para>Windows example, installing in the <code>C:\moin</code> directory: </para><screen><![CDATA[> python setup.py --quiet install --prefix="C:\moin" --record=install.log]]></screen><para>All MoinMoin files will then be installed inside those directories, see <code>install.log</code> to know which files were installed, and where. </para><para><emphasis role="strong">Note:</emphasis> You will likely see the following warning: </para><itemizedlist><listitem override="none"><para><code>warning: install: modules installed to 'C:\moin\', which</code></para><para> <code>is not in Python's module search path (sys.path) -- you'll</code></para><para> <code>have to change the search path yourself</code> </para></listitem></itemizedlist><para>This means exactly what it says, you need to add your install directory to the search path of Python, or it won't find the MoinMoin code. </para><para>For example, if you are running using a webserver and standard CGI, edit <code>moin.cgi</code> and add your installation directory to the Python path, like this: </para><screen><![CDATA[import sys
sys.path.insert(0, 'C:/moin')]]></screen></section></section><section><title>Test installation</title><para>As a final step, if you have access to the shell or the command prompt, you can check that everything is correctly installed and ready to run. Start Python and type <code>import MoinMoin</code>. Nothing should be displayed in response to this command. Example: </para><screen><![CDATA[> python
Python 2.4.4 (...)
Type "help", "copyright", "credits" or "license" for more information.
>>> import MoinMoin
>>>]]></screen><para>If you get this instead: </para><screen><![CDATA[>>> import MoinMoin
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named MoinMoin
>>>]]></screen><para>then you have to tune your installation. Try modifying <code>sys.path</code>, as described above. </para></section><section><title>What has been installed</title><para>So, you have a ready-to-work MoinMoin installation now. Congratulations! Before you go on to configuring it, take a look at the various files and directories that have been installed. </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> It is important that you understand the different locations used in a MoinMoin setup, so read this carefully. </para><para>In the following descriptions, <code>PREFIX</code> is what you used with the <code>setup.py</code> command, or a default location if you didn't use the <code>--prefix</code> option. (Typical default values on Linux are <code>/usr</code> and <code>/usr/local</code>.) <code>X.Y</code> is the version of Python. Typically, this is <code>2.3</code>, <code>2.4</code> or <code>2.5</code>. </para><para>Look into <code>install.log</code> to find out about following important locations: </para><itemizedlist><listitem><para><emphasis role="strong"><code>MoinMoin</code> directory</emphasis>, usually <code>PREFIX/lib/pythonX.Y/site-packages/MoinMoin</code> -- this is where the MoinMoin <emphasis role="strong">source code</emphasis> is located </para></listitem><listitem><para><emphasis role="strong"><code>share</code> directory</emphasis>, usually <code>PREFIX/share/moin</code> - this is where the <emphasis>templates</emphasis> are located </para><itemizedlist><listitem><para><emphasis role="strong"><code>data</code></emphasis> directory (wiki pages, users, etc.) - only MoinMoin should access this </para></listitem><listitem><para><emphasis role="strong"><code>underlay</code></emphasis> directory (wiki pages) - only MoinMoin should access this </para></listitem><listitem><para><emphasis role="strong"><code>htdocs</code></emphasis> directory with html support files (images for the various themes, etc.) - the web server will need to access this </para></listitem><listitem><para><emphasis role="strong"><code>server</code></emphasis> - MoinMoin example startup files (like <code>moin.cgi</code> for CGI, and other files for other startup methods) </para></listitem><listitem><para><emphasis role="strong"><code>config</code></emphasis> - MoinMoin example configuration files (like <code>wikiconfig.py</code>) </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong"><code>bin</code></emphasis> directory with some scripts that help you use the MoinMoin shell commands </para></listitem></itemizedlist><para>We talk of <emphasis>templates</emphasis> in the <code>share</code> 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. </para></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="wikiinstance-creation"/> </para><para>After you have downloaded and installed MoinMoin, you will want to &quot;have a wiki&quot;. As explained at the bottom of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink>, 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. </para><para>Every time you copy those files (and modify the configuration of your server accordingly), you create what is called a <emphasis>wiki instance</emphasis>. Each wiki instance is independent from the others, with a different configuration, different pages, different users, etc. </para><para>Some of the steps you need to take depend on which web server and which operating system you use. They are described on dedicated pages, which you should read (at least the beginning) before reading this one. Some other steps are common to every webserver and operating system (copying files around, setting permissions), and this is what is described here. </para><para>Linux users can use <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation?action=AttachFile&amp;do=get&amp;target=createinstance.sh">createinstance.sh</ulink> (a bash script that creates the instance) instead of doing all steps manually: </para><orderedlist numeration="arabic"><listitem><para>If anything is unclear, just read the sections below for more hints. </para></listitem><listitem><para>Have a look into the script before running it, if all settings are correct for your setup: </para><itemizedlist><listitem><para>USER and GROUP should be the user and group used by your web-server for running moin. </para></listitem><listitem><para>SHARE is where the shared files were copied to, see install.log from the <code>setup.py install</code> step </para></listitem></itemizedlist></listitem><listitem><para>The script takes a single parameter: the location of your wiki instance (see &quot;Choose a location&quot; section below): </para><screen><![CDATA[# ./createinstance.sh /path/to/mywiki]]></screen></listitem><listitem><para>Now continue in section &quot;Tune configuration&quot; </para></listitem></orderedlist><section><title>Read this first</title><section><title>Security warnings</title><informaltable><tgroup cols="1"><colspec colname="col_0"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para> <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> <emphasis role="strong">Warning: make sure that your <code>data</code> directory and your configuration files are not accessible through your web server. Do not put your wiki directory in <code>public_html</code>, <code>Sites</code> or any other directory your web server can access. The web server only needs to access the file in the <code>htdocs</code> directory and the <code>moin.cgi</code> script! (Or whatever script your server uses to start MoinMoin.)</emphasis> </para></entry></row></tbody></tgroup></informaltable><informaltable><tgroup cols="1"><colspec colname="col_0"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para> <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> <emphasis role="strong">Warning: make sure that the <code>data</code> directory and its subdirectories are not readable and not writeable by users other than the web server user. If you need to give worldwide read-write permissions to get it working, be aware that you are doing a very unsecure setup, that can be compromised by any other user or program on your computer.</emphasis> </para></entry></row></tbody></tgroup></informaltable></section><section><title>Note to Windows users</title><para>All the commands below are Linux commands. The text descriptions that introduce them should be enough to help you understand what you need to do. Use the Windows Explorer, or the appropriate text-mode commands. </para></section></section><section><title>Choose a wiki name</title><para>Choose a unique name for the new wiki instance you want to create. It should be a short word, something that reflects what you intend to use the wiki for, like the name of your organization, of your team, of the project you are working on, etc. </para><para>The name &quot;<code>mywiki</code>&quot; is used as an example in the various commands below. </para></section><section><title>Choose a location</title><para>Choose a directory on your disk, it will contain all the files needed for your wiki instance. At the beginning, your wiki instance will use approximately 10 MB of disk space. Then of course, it will grow depending on the way your wiki is used. A personal wiki, even with many pages, might only use 30 MB or 40 MB of disk space. A popular wiki, or a wiki with many files attached to the pages, might use much more, of course. </para><para>If you are the administrator (or root) of the server, you can use anything you like or that makes sense to you, for example <code>/usr/local/var/moin</code>, <code>/mnt/wikis</code>, etc. </para><para>If you are a simple user, you will probably only be allowed to write in your personal, &quot;home&quot; directory. Choose a subdirectory that makes sense to you, for example the <code>share/moin</code> subdirectory. </para></section><section><title>Collect some important information</title><para>This is where the instructions differ according to the web server and operating system you use, and whether you are the administrator or a simple user. See the appropriate pages for your web server and operating system combination. </para><para>On Linux, the <code>export</code> command will be used to remember the collected information. Windows users should write it down carefully (maybe cutting-and-pasting in a Notepad window), or store it in environment variables if they use the command prompt. </para><itemizedlist><listitem><para><code>PREFIX</code> is the prefix you used during the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink> </para></listitem><listitem><para><code>SHARE</code> is the name of the <code>share</code> directory, as discussed at the bottom of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink> </para></listitem><listitem><para><code>WIKILOCATION</code> is the name of the directory that will contain your wiki instance </para></listitem><listitem><para><code>INSTANCE</code> is the directory containing the wiki instance. It cannot be an existing directory readable through Apache, otherwise it will fail. </para></listitem></itemizedlist><para>If you are an administrator, you also need to collect the following: </para><itemizedlist><listitem><para><code>USER</code> is the user name of the web server </para></listitem><listitem><para><code>GROUP</code> is the name of the group to which the web server belongs </para></listitem></itemizedlist><para>Now, Linux folks, let's store these settings in memory: </para><screen><![CDATA[> export PREFIX=/usr                # this might be something else
> export SHARE=$PREFIX/share/moin   # this should be correct for most people
> export WIKILOCATION=$SHARE        # this is just an example
> export INSTANCE=mywiki            # this is just an example]]></screen><para>Administrators also need the following two lines: </para><screen><![CDATA[> export USER=www-data              # this is just an example
> export GROUP=www-data             # this is just an example]]></screen></section><section><title>Copy the files</title><para>To create your new instance, you first need to create a directory named like your instance, inside the <code>WIKILOCATION</code>. Then you need to copy the <code>data</code> and <code>underlay</code> directories from your <code>SHARE</code> directory into your instance directory. Finally, you need to copy the <code>wikiconfig.py</code> file from the <code>config</code> directory into the instance directory. </para><para>Linux folks need to just type these commands: </para><screen><![CDATA[> cd $WIKILOCATION
> mkdir $INSTANCE                   # make a directory for this instance
> cp -R $SHARE/data $INSTANCE       # copy template data directory
> cp -R $SHARE/underlay $INSTANCE   # copy underlay data directory
> cp $SHARE/config/wikiconfig.py $INSTANCE   # copy wiki configuration sample file]]></screen><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> Note that you just need to keep one underlay directory on your system if you are running multiple wikis (e.g. in a farm.) </para></listitem></itemizedlist></section><section><title>Set permissions</title><section><title>Administrators</title><para>Administrators need to restrict the permissions of the files, so that only the web server (and the administrator of course) can read and write them. For maximum security, no other user on the machine should be able to read or write anything in the wiki instance directory. Don't forget that this directory contains sensitive information, notably the (encrypted) passwords of the wiki users. </para><para>On Linux, the following commands should be enough: </para><screen><![CDATA[> chown -R $USER.$GROUP $INSTANCE   # check that USER and GROUP are correct
> chmod -R ug+rwX $INSTANCE         # USER.GROUP may read and write
> chmod -R o-rwx $INSTANCE          # everybody else is rejected]]></screen></section><section><title>Normal users</title><para>Normal users, on the contrary, need to broaden the permissions of the files, so that the web server can read and write them. On recent Windows versions, and on some versions of Linux and other systems, <emphasis>access control lists</emphasis> can be used to that effect. They are, however, powerful and complicated, much beyond the scope of this document. Ask a knowledgeable person about them. </para><para>Without them, normal users have to allow <emphasis>everybody</emphasis> to access the instance directory. This is the only way the web server can enter it and do its work. This is, of course, <emphasis role="strong">VERY INSECURE</emphasis>, since any other user and program on the server can read the directory. You should <emphasis role="strong">not</emphasis> use such a setup for a wiki open to the public. </para><para>On Linux, the following commands will open the instance directory to the whole world: </para><screen><![CDATA[> chmod -R a+rwX $INSTANCE]]></screen><para><emphasis role="strong">Note:</emphasis> </para><itemizedlist><listitem><para>it is also possible to put the web server and the normal user in the same <emphasis>group</emphasis>, and then only open the instance directory to the members of that group. This is a bit more secure (depending on who else is in the group), but you need the cooperation of the server administrator; he is the one setting up groups. </para></listitem><listitem><para>the best other possibility is that the server administrator sets up <code>suexec</code> to execute CGI scripts in user directories under the user id of that user. You don't need to give world permissions that way, so it is a quite secure setup, but you also need cooperation of the administrator. </para></listitem></itemizedlist></section></section><section><title>Tune configuration</title><para>Now, you need to tune the configuration of your web server and of your wiki instance. Look at the appropriate help page for your web server, then come back here to tune the settings of your wiki instance. </para><para>Edit <code>wikiconfig.py</code>. The default settings should work fine in most cases, but there are some things that you will probably want to change, like the name and logo of your wiki! <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/smile.png" width="16"/></imageobject><textobject><phrase>:)</phrase></textobject></inlinemediaobject> Read the comments inside <code>wikiconfig.py</code>, they will guide you through this process. </para><informaltable><tgroup cols="1"><colspec colname="col_0"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para> <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> <emphasis role="strong">Warning: don't forget to restart your web server in order to apply changes in <code>wikiconfig.py</code></emphasis> </para></entry></row></tbody></tgroup></informaltable><para><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnConfiguration#">HelpOnConfiguration</ulink> contains all the details about all the options, in case the comments in <code>wikiconfig.py</code> are not enough. </para></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="linuxapache-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnLinux">Linux Installation using Apache</ulink></title><para>This page describes the particular steps that need to be taken to create a wiki instance using <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> on Linux with the Apache web server. <emphasis role="strong">You should have already performed the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink>. </emphasis>Installations on other Unices like FreeBSD are very similar. </para><para>On this page two installation scenarios are discussed: </para><orderedlist numeration="arabic"><listitem><para>You have <emphasis role="strong">Administrator Rights </emphasis>(you are user 'root' or may use sudo)  for a server and are able to install and modify files almost anywhere on the machine, and notably able to modifiy the Apache configuration. </para></listitem><listitem><para>You are a <emphasis role="strong">Simple User,</emphasis> only able to write files into your home directory, and unable to alter the master Apache configuration file. </para></listitem></orderedlist><para>The following options are not mentioned here: </para><itemizedlist><listitem><para>using <emphasis role="strong">suEXEC</emphasis> </para></listitem><listitem><para>using <emphasis role="strong">FastCGI </emphasis> (see <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/FastCgi#">../FastCgi</ulink>) </para></listitem><listitem><para>using <emphasis role="strong">mod_python</emphasis> (see <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheWithModPython#">../ApacheWithModPython</ulink>) </para></listitem><listitem><para>setting up a <emphasis role="strong">Root Wiki</emphasis> (see <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnConfiguration/ApacheVoodoo#">HelpOnConfiguration/ApacheVoodoo</ulink>) </para></listitem><listitem><para>For more advanced configurations and some tricks see also <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpMiscellaneous#">HelpMiscellaneous</ulink>. </para></listitem></itemizedlist><para><emphasis role="strong">Table of contents</emphasis> <!--The macro TableOfContents doesn't work with the DocBook formatter.--> </para><section><title>Administrator Scenario</title><para>The exact location of the various Apache configs varies - often used locations are: <code>/etc/httpd/, /etc/apache/ or /etc/apache2/</code>. You should have at least <emphasis>some</emphasis> know-how of how to set up and deal with Apache, especially when it comes to virtual host setup. If you do not know what we are talking about, please read about <emphasis>Configuration Files</emphasis> and <emphasis>Apache Virtual Host documentation </emphasis>in the <ulink url="http://httpd.apache.org/docs/">Apache documentation</ulink>. </para><para>On Apache2 it is quite usual to have a directory (like /etc/httpd/conf.d) for virtual hosts. So every file ending with <emphasis>.conf</emphasis> will be included into the main Apache configuration file. To look if this is true for your configuration, search for the word &quot;Include&quot;. </para><section><title>Create a wiki instance</title><para>Creating a wiki instance involves copying files around and setting appropriate permissions. Before you can proceed, you need to know what user and group your Apache server runs as. The easiest way to know this is to issue this command: </para><screen><![CDATA[> egrep "^User|^Group" /etc/httpd/httpd.conf
User wwwrun
Group nogroup]]></screen><para>This shows a typical result: &quot;<code>wwwrun.nogroup</code>&quot;. Other common results are &quot;<code>nobody.nogroup</code>&quot;, &quot;<code>apache.apache</code>&quot; and &quot;<code>www-data.www-data</code>&quot;. You can of course use your own. What matters is that you know which ones are in use, because you will need them to set file permissions. </para><para>Once you have gathered this information, read <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink> and follow the steps described there. </para></section><section><title>Install moin.cgi</title><para>There is one last file you need to copy, the bridge between Apache and MoinMoin: the CGI script that Apache will call every time a wiki page is requested, and that will in turn invoke all the MoinMoin components to handle the request. You can actually put this script anywhere you like (all the paths to the files MoinMoin needs can be configured to match your filesystem layout), but for the sake of simplicity and security, we suggest you follow the instructions below, unless you think you know better. </para><para>We will create a <code>cgi-bin</code> subdirectory in the instance directory. Using the environment variables defined in <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink>, run the following commands: </para><screen><![CDATA[> cd $WIKILOCATION/$INSTANCE
> mkdir cgi-bin
> cp $SHARE/server/moin.cgi cgi-bin
> chown -R $USER.$GROUP cgi-bin
> chmod -R ug+rx cgi-bin
> chmod -R o-rwx cgi-bin]]></screen></section><section><title>Configure moin.cgi</title><para>When <code>moin.cgi</code> is launched, it imports a MoinMoin module that in turn imports other modules and the configuration file. While the MoinMoin modules should always be found in a properly configured system (as described in <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink>), it is likely that the configuration file will not be found. Edit the <code>moin.cgi</code> script to correct that. Add these lines near the top of the file: </para><screen><![CDATA[import sys
sys.path.insert(0, '..')]]></screen><para>An even better way is to use the absolute path name of the directory that contains the <code>wikiconfig.py</code> file instead of <code>'..'</code>. </para></section><section><title>Configure Apache</title><para>Now that every file is in place and properly locked down (as far as the filesystem is concerned), we need to configure Apache so that it offers access to the right files, and no others. However, since the default Apache configuration varies a lot depending on the distribution you use, and since administrators often make important additions and changes to it, we cannot give exact instructions that cover all cases. Instead, we will first describe roughly what needs to be done, and then give a few specific lines that you should add at the appropriate place in your Apache config. </para><para>Your Apache should be set up so that: </para><itemizedlist><listitem><para>Access to your instance directory is denied (sane Apache installations should actually deny access to the whole server, and then only allow a few specific directories). </para></listitem><listitem><para>An <emphasis role="strong">Alias</emphasis> is set up to redirect requests from <code>/moin_static160/</code> (in the URL - see also <code>url_prefix_static</code> configuration variable) to the <code>htdocs</code> directory (in the <code>share</code> directory, as discussed at the bottom of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink>). Please note that <code>url_prefix_static</code> will change with every moin release! </para></listitem><listitem><para>A <emphasis role="strong">ScriptAlias</emphasis> is set up to redirect requests from whatever you want (we suggest you use your instance name, for example <code>/mywiki</code>) to the CGI script you just copied. </para></listitem></itemizedlist><para>The following commands will add two lines at the bottom of your Apache config file. These lines only cover the last two items listed above. You have to check the first one by yourself (there is too much variation in Linux distributions). Note that you may have to move the two lines to the appropriate place in your config file -- maybe near other similar lines. </para><screen><![CDATA[> echo "" >>/etc/httpd/httpd.conf
> echo "Alias /moin_static160/ \"$SHARE/htdocs/\"" >>/etc/httpd/httpd.conf
> echo "ScriptAlias /mywiki \"$WIKILOCATION/$INSTANCE/cgi-bin/moin.cgi\"" >>/etc/httpd/httpd.conf]]></screen><para>So this would add two lines like the both below to a config file (possibly you use one for each virtual server): </para><screen><![CDATA[Alias /moin_static160/ /usr/local/share/htdocs/
ScriptAlias /mywiki /usr/local/share/moin/mywiki/cgi-bin/moin.cgi]]></screen><para>You only need to define the Alias for <code>htdocs</code> once, no matter how many wikis you run with the 1.6.0 version of moin. You need to define a different script alias for each wiki instance you intend to run. So you could also define the Alias in a central Apache configuration file and only define the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/ScriptAlias#">ScriptAlias</ulink> in virtual host configurations. </para></section><section><title>Configure MoinMoin</title><para>Finally, check that the <code>wikiconfig.py</code> file in the instance directory contains correct paths for: </para><itemizedlist><listitem><para><code>url_prefix_static</code> (static stuff like css/img/js) </para></listitem><listitem><para><code>data_dir</code> (the instance data directory) and </para></listitem><listitem><para><code>data_underlay_dir</code> (the instance underlay directory). </para></listitem></itemizedlist><para>You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! Better <emphasis role="strong">use absolute paths</emphasis>, and save yourself some headaches. </para><para>Here are the settings you should have in the config file if you followed all our suggestions: </para><screen><![CDATA[    data_dir = '../data/'  # better use absolute path
    data_underlay_dir = '../underlay/'  # better use absolute path
    url_prefix_static = '/moin_static160' # depends on moin version]]></screen><para>There are other settings you will likely want to alter, look at the bottom of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink> for more details about them. </para></section><section><title>Test the wiki</title><para>Everything should work fine now. It is time to <emphasis role="strong">restart the Apache server</emphasis> (usually with &quot;<code>/etc/init.d/apache restart</code>&quot;, sometimes with &quot;<code>apachectl restart</code>&quot;) and perform the following steps: </para><itemizedlist><listitem><para>Run the <emphasis>MoinMoin CGI Diagnosis</emphasis>: connect to &quot;<code>http://127.0.0.1/mywiki?action=test</code>&quot; (or the name and port you have defined in the Apache configuration file). Verify that the displayed information is correct. Check that the directories listed under <emphasis>Checking directories...</emphasis> are <emphasis>OK</emphasis>. </para></listitem><listitem><para>Access your new wiki with the URL &quot;<code>http://127.0.0.1/mywiki/</code>&quot; (or the name and port you have defined in the Apache configuration file). You should see some wiki page - read it. </para></listitem><listitem><para>Then go to the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/WikiSandBox#">WikiSandBox</ulink> page. </para></listitem><listitem><para>Try to edit it and save your changes. </para></listitem><listitem><para>If that works, see if your edit is reflected on the RecentChanges page. </para></listitem><listitem><para>If you see them, congratulations, your new wiki works! <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/smile.png" width="16"/></imageobject><textobject><phrase>:)</phrase></textobject></inlinemediaobject> </para></listitem></itemizedlist><para>If something goes wrong, have a look at Troubleshooting, at the bottom of this page. </para></section></section><section><title>Simple User Scenario</title><para>On machines shared by many people, simple users typically have no access to the root account, cannot modify the <code>httpd.conf</code> file, and cannot copy files into the system-wide <code>cgi-bin</code> and <code>htdocs</code> directories. In that case, Apache can be set up so that each user can host a web site in the home directory of his or her shell account, using the <code>UserDir</code> directive. If the machine administrator decides to use it, all URLs that start with &quot;<code>/~username</code>&quot; will be redirected to a directory in the users' home directories, where they have write permission and can install MoinMoin. </para><para>As an example, we will consider the case of a user named &quot;<code>mm</code>&quot;. Of course, wherever you see &quot;<code>mm</code>&quot; below, you will replace it with your own username. </para><section><title>Make sure /~username works</title><para>The home directory installation can only work if the administrator (root) has allowed it. So, the first step is of course to check that it works. Typically, Apache is set up so that the <code>public_html</code> subdirectory in the home directory is used as the web site root. So, the first first step is to check if that directory exists. </para><screen><![CDATA[> ls -ld ~/public_html
drwxr-xr-x   2 mm       users        4096 Nov 30 00:29 public_html]]></screen><para>If the directory does not exist, create it, and be sure it can be read and entered by the web server. </para><screen><![CDATA[> mkdir public_html
> chmod a+rx public_html
> ls -ld ~/public_html
drwxr-xr-x   2 mm       users        4096 Nov 30 00:35 public_html]]></screen><para>Now, check if the &quot;<code>/~mm</code>&quot; URL works: </para><screen><![CDATA[> lynx -error_file=/dev/stderr -dump http://localhost/~mm/ >/dev/null
URL=http://localhost/~mm/ (GET)
STATUS=HTTP/1.1 200 OK]]></screen><para>If you get a &quot;<code>200 OK</code>&quot; response code, then it works, and you can go on to the next check. If you get a &quot;<code>403 Forbidden</code>&quot; or a &quot;<code>404 Not Found</code>&quot; response, then maybe something is wrong with your directory, or maybe the whole thing has not been enabled by your administrator. </para><itemizedlist><listitem><para>Check the permissions for your home directory (<code>~</code>) and your <code>public_html</code> directory. The first one should at least end with &quot;<code>--x</code>&quot;, and the second one, as we saw above, with &quot;<code>r-x</code>&quot;. </para></listitem><listitem><para>It also possible that the administrator has set up another name for the personal web site directory. &quot;<code>public_html</code>&quot; is just the usual default, but anything can actually be used. There is no way to know, you have to ask the administrator (root). </para></listitem><listitem><para>Finally, if the personal web site feature is disabled, maybe you can ask the administrator to enable it? </para></listitem></itemizedlist><para>Once you have checked you can read the files in the directory, you need to check that you are also able to execute CGI scripts in that directory. Use the following commands to create a simple CGI script in the appropriate location: </para><screen><![CDATA[> mkdir -p ~/public_html/cgi-bin
> cat > ~/public_html/cgi-bin/test.cgi
#!/bin/sh
echo Content-Type: text/plain
echo
echo "CGI scripts work"
<CTRL-D>
> chmod a+rx ~/public_html/cgi-bin/test.cgi
> lynx -dump http://localhost/~jh/cgi-bin/test.cgi
CGI scripts work]]></screen><para>If you get anything else than &quot;<code>CGI scripts work</code>&quot;, then something went wrong. Check the directory permissions as above, try other names (or ask about them). The sad truth might be that you are not allowed to execute CGI scripts. You would then have to ask the administrator (root) for that permission. </para><para>Once you get it, you can set up your wiki instance in the <code>public_html</code> directory. <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/smile.png" width="16"/></imageobject><textobject><phrase>:)</phrase></textobject></inlinemediaobject> </para></section><section><title>Create a wiki instance</title><para>Creating a wiki instance involves copying files around and setting appropriate permissions. Read <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink> and follow the steps described there. </para></section><section><title>Install the htdocs files</title><para>The web server needs to access these files, so we need to copy them into the &quot;<code>public_html</code>&quot; directory. Just use this: </para><screen><![CDATA[> cd ~/public_html
> cp -R ~/share/moin/htdocs moin_static160
> chmod -R a+rX moin_static160]]></screen></section><section><title>Install moin.cgi</title><para>There is one last file you need to copy, the bridge between Apache and MoinMoin: the CGI script that Apache will call every time a wiki page is requested, and that will in turn invoke all the MoinMoin components to handle the request. You need to put this file in a directory for which CGI scripts execution is enabled. By default, this should work: </para><screen><![CDATA[> cd ~/public_html
> mkdir cgi-bin
> cp $SHARE/server/moin.cgi cgi-bin
> chmod -R a+rx cgi-bin]]></screen></section><section><title>Configure moin.cgi</title><para>When <code>moin.cgi</code> is launched, it imports a MoinMoin module (that in turn imports other modules and the configuration file). Since everything has been installed in your home directory, it is likely none of these will be found. Edit the <code>moin.cgi</code> script to correct that. Add these lines near the top of the file: </para><screen><![CDATA[import sys
sys.path.insert(0, '/home/mm/lib/python2.4')
sys.path.insert(0, '/home/mm/lib/python2.4/site-packages')
sys.path.insert(0, '/home/mm/share/moin/mywiki')]]></screen><para>Of course, you need to adapt the paths to your situation. The first two lines should help locate the MoinMoin modules, the last one should help locate the <code>wikiconfig.py</code> file. </para><para><emphasis role="strong">Note:</emphasis> You might also need to edit the first line of the file, to point to the correct version of Python. The default should be fine, but a line like &quot;<code>#! /usr/bin/python2.4</code>&quot; might help you if the default does not work. </para><para><emphasis role="strong">Note 2:</emphasis> In this file there is a line reading <code>request = RequestCGI()</code>. If you have a complex mod_rewrite case, you might want to add <code>properties = {'script_name': '/mywiki'} </code> in the parentheses. This will let <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> generate URLs that start with <code>/mywiki</code> and not the path that the webserver passed to <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink>: </para><screen><![CDATA[def handle_request(req, env, form):
    request = RequestCGI(req, env, form, properties = {'script_name': '/mywiki'})
    request.run()]]></screen></section><section><title>Configure MoinMoin</title><para>Finally, check that the <code>wikiconfig.py</code> file in the instance directory contains correct paths for <code>url_prefix_static</code> (the htdocs directory), <code>data_dir</code> (the instance data directory) and <code>data_underlay_dir</code> (the instance underlay directory). You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! It is better to use <emphasis role="strong">absolute paths</emphasis>, and save yourself some headaches. </para><screen><![CDATA[    data_dir = '/home/mm/share/moin/mywiki/data/'
    data_underlay_dir = '/home/mm/share/moin/mywiki/underlay/'
    url_prefix = '/~mm/moin_static160']]></screen></section><section><title>Test the wiki</title><para>Everything should work fine, now. It is time to perform the following steps: </para><itemizedlist><listitem><para>Run the <emphasis>MoinMoin CGI Diagnosis</emphasis>: <code>&gt; lynx -dump http://localhost/~mm/cgi-bin/moin.cgi?action=test</code> </para></listitem><listitem><para>If it worked, try to access your new-born wiki with the URL &quot;<code>http://127.0.0.1/~mm/cgi-bin/moin.cgi</code>&quot;. You should see some wiki page - read it. </para></listitem><listitem><para>Now go to the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/WikiSandBox#">WikiSandBox</ulink> page. </para></listitem><listitem><para>Try to edit it and save your changes. </para></listitem><listitem><para>If that works, see if your edit is reflected on the RecentChanges page. </para></listitem><listitem><para>If you see them, congratulations, you have a new wiki! <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/smile.png" width="16"/></imageobject><textobject><phrase>:)</phrase></textobject></inlinemediaobject> </para></listitem></itemizedlist><para>If something goes wrong, have a look at Troubleshooting, below. </para></section></section><section><title>Troubleshooting</title><para>See also <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/TroubleShooting#">../TroubleShooting</ulink> for generic stuff. </para><para>The first thing to do when your wiki does not work as expected is to issue the command &quot;<code>tail /var/log/httpd/error_log</code>&quot; to display the most recent errors. Usually, you will get a hint on what went wrong, like missing file system permissions. </para><section><title>Adding permission to serve the htdocs directory</title><para>In some (sane) Linux distributions (like SuSE 9.0) serving directories other than the document-root &quot;<code>/srv/www/htdocs</code>&quot; with Apache is switched off by default for security reasons in &quot;<code>/etc/httpd/httpd.conf</code>&quot; (or for Apache2 &quot;<code>/etc/apache2/httpd.conf</code>&quot;): </para><screen><![CDATA[# forbid access to the entire filesystem by default
<Directory />
  Options None
  AllowOverride None
  Order deny,allow
  Deny from all
</Directory>]]></screen><para>To allow Apache to serve directories outside of the document root you have to add these lines to &quot;<code>/etc/httpd/httpd.conf</code>&quot; (in SuSE it is recommended to create a new &quot;<code>http.conf.local</code>&quot; and include this file in &quot;<code>/etc/sysconfig/apache2</code>&quot;): </para><screen><![CDATA[Alias /wiki/ "/usr/share/moin/htdocs/"
<Directory "/usr/share/moin/htdocs/">
   Order deny,allow
   Allow from all
</Directory>
ScriptAlias /mywiki "/usr/share/moin/mywiki/cgi-bin/moin.cgi"
<Directory "/usr/share/moin/mywiki/cgi-bin">
   Order deny,allow
   Allow from all
</Directory>]]></screen><para>Of course, you need to adapt the paths to your particular situation. </para></section></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="fastcgi-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/FastCgi">FastCGI Setup using Apache or Lighttpd</ulink></title><para>FastCGI is a method which enables a web server to communicate with long-running scripts. This has the advantage that the script is only started and initialized one time, and that data could be cached in memory from request to request, enhancing the performance of the CGI application. </para><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> Follow the basic installation for your operating system as described in other parts of the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> installation documentation. This is <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">HelpOnInstalling/BasicInstallation</ulink> and <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">HelpOnInstalling/WikiInstanceCreation</ulink>, or <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnLinux#">HelpOnInstalling/ApacheOnLinux</ulink> in most cases.  </para></listitem></itemizedlist><section><title>Using MoinMoin with FastCgi</title><para>For more general information: </para><itemizedlist><listitem><para><ulink url="http://fastcgi.com"/> - FastCGI Homepage </para></listitem><listitem><para><ulink url="http://cryp.to/publications/fastcgi/">FastCGI — The Forgotten Treasure</ulink> (introduction) </para></listitem></itemizedlist></section><section><title>Deploying on Apache</title><para>To deploy <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> using FastCGI you need an apache with mod_fastcgi. Please refer to the documentation of mod_fastcgi ( <ulink url="http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html">mod_fastcgi homepage</ulink> ). </para><para>Don't forget to install the fastcgi Apache module (e.g. libapache2-mod-fastcgi). Then in places where the documentation refers to <code>moin.cgi</code> you use <code>moin.fcg</code> instead. Be sure that <emphasis role="strong">.fcg</emphasis> is handled by the FastCGI module (<code>AddHandler fastcgi-script .fcg</code> in your apache config). </para><para>Normally Apache will start CGI scripts with its own user and group, or with the user and group of the VirtualHost if you are using the suexec wrapper. To enable this with FastCGI you need to use <code>FastCgiWrapper On</code> in your Apache config (check your distributions and/or FastCGI Documentation). </para><para>Be sure to restart your Apache after you changed py files (i.e. the config) for a running FastCGI server, or you won't see any changes! </para><section><title>Script options</title><para>No matter how and where you install or how you configure, you can add some options (in Apache config or as self-running process). Here is a list of some options. </para></section><section><title>FastCgiExternalServer</title><screen><![CDATA[-host [hostname:port]     - The port and on what host name to respond.
-idle-timeout [seconds]   - The number of seconds of inactivity allowed before request is aborted.]]></screen></section><section><title>FastCgiServer</title><screen><![CDATA[-port [port]              - The port the application will use for communication with the web server.
-idle-timeout [seconds]   - The number of seconds of inactivity allowed before request is aborted.]]></screen></section><section><title>Example for Apache2 on Debian</title><para>Edit the /etc/apache2/conf.d/your_wiki: </para><screen><![CDATA[<IfModule mod_fastcgi.c>
   AddHandler fastcgi-script .fcgi .fcg
   FastCgiServer /your/path/to/moin.fcg -idle-timeout 60 -processes 1
   ScriptAlias /your_wiki "/your/path/to/moin.fcg"
</IfModule>]]></screen><itemizedlist><listitem><para>number of processes depends on your hardware.. </para></listitem></itemizedlist><para>Expand the Apache installation: </para><screen><![CDATA[apt-get install libapache2-mod-fastcgi
a2enmod fastcgi
apache2ctl graceful]]></screen><para>Now, your wiki should respond a little faster. </para></section><section><title>Running as an external application and/or on Windows</title><para><emphasis>(see also <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnWin32withFastCgi#">../ApacheOnWin32withFastCgi</ulink> for a Windows-specific how-to)</emphasis> </para><para>MoinMoin can be run as an external application that answers FastCGI request via a local TCP/IP socket. This works on Windows as well. All you need to do (after having installed <code>mod_fastcgi</code> and a working MoinMoin instance) is this: </para><orderedlist numeration="arabic"><listitem><para>Select a port number for the internal communication. It should be larger than 1023. For this example, we chose 8888 (just for fun). </para></listitem><listitem><para>Add the following lines to your httpd.conf:</para><screen><![CDATA[Alias /moin.fcg "/your/path/to/moin.fcg"
FastCgiExternalServer "/your/path/to/moin.fcg" -host localhost:8888]]></screen></listitem><listitem><para>Edit <code>moin.fcg</code>. Replace</para><screen><![CDATA[fcg = thfcgi.FCGI(handle_request, max_requests=max_requests, backlog=backlog, max_threads=max_threads)]]></screen><para> with </para><screen><![CDATA[fcg = thfcgi.FCGI(handle_request, 0, 8888, max_requests=max_requests, backlog=backlog, max_threads=max_threads)]]></screen></listitem><listitem><para>Start the file <code>moin.fcg</code> manually like a Python script:</para><screen><![CDATA[python moin.fcg]]></screen></listitem><listitem><para>Start Apache. </para></listitem></orderedlist></section><section><title>Fallback to CGI if FastCGI is not available</title><para>Install and test <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> according to <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnLinux#">HelpOnInstalling/ApacheOnLinux</ulink>. Then make and test the changes to run mod_fastcgi. If you are satisfied, you can add the following block to your apache config: </para><screen><![CDATA[<IfModule !mod_fastcgi.c>
    ScriptAlias /mywiki "/your/path/to/moin.cgi"
</IfModule>
<IfModule mod_fastcgi.c>
    AddHandler fastcgi-script .fcg
    ScriptAlias /mywiki "/your/path/to/moin.fcg"
</IfModule>]]></screen><para>Now Apache will use mod_fastcgi if available and otherwise use the slow cgi script. </para></section></section><section><title>Deploying on lighttpd</title><para>This is about running a wiki under &quot;/&quot; URL with lighttpd. </para><para>The moin.fcg processes will get spawned by lighttpd automatically (thus, if you want to restart moin, just restart lighttpd). </para><para>It will also take care about handling robots.txt and favicon.ico correctly. </para><para>First add fastcgi and rewriting support to your lighttpd.conf (if you don't already have it): </para><screen><![CDATA[server.modules              = (
                                "mod_access",
                                "mod_rewrite",      # <--- IMPORTANT!
                                "mod_status",
                                "mod_fastcgi",      # <--- IMPORTANT!
                                "mod_accesslog",
                                "mod_redirect",
                                "mod_auth",
                                "mod_expire",
)]]></screen><para>Then configure it to run moin.fcg for your wiki site and also serve the static stuff: </para><screen><![CDATA[$HTTP["host"] =~ "^(www\.)?example\.org" {
    url.rewrite-once = (
        "^/robots.txt" => "/robots.txt",
        "^/favicon.ico" => "/favicon.ico",
        "^/moin_static161/(.*)" => "/moin_static161/$1",
        "^/(.*)" => "/wiki-engine/$1"
    )
    server.document-root        = "/srv/org.example/htdocs/"
    $HTTP["url"] =~ "^/wiki-engine/" {
      fastcgi.server = ( "/wiki-engine" =>
        (( "docroot"   => "/",
           "min-procs" => 10,
           "max-procs" => 10,
           "max-load-per-proc" => 2,
           # allocate successive port numbers for each process, starting with "port"
           "bin-path"  => "/srv/org.example/bin/moin.fcg",
           "host"      => "127.0.0.1",
           "port"      => 3060,
           "check-local" => "disable",
        ))
      )
    }
}]]></screen><para>Finally adapt moin.fcg: </para><screen><![CDATA[class Config(FastCgiConfig):
    loglevel_file = logging.INFO
    logPath = '/srv/org.example/logs/moin.log'
    max_requests = 1000
    properties = {'script_name': '/'}  # <--- IMPORTANT!]]></screen><section><title>Using HTTP Authentication</title><para>lighttpd mod_fastcgi does not add the AUTH_TYPE variable to the cgi environment, which will cause http auth in moin to fail.   See <ulink url="http://trac.lighttpd.net/trac/ticket/889"/> for more information, and an attached diff file to correct to issue. </para></section><section><title>MoinMoin Startup script</title><para>Here is a startup script for Mac OS X, using <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/DarwinPortsStartup#">DarwinPortsStartup</ulink> system. It is probably useful for other unix like platforms. </para><screen><![CDATA[# Start and stop multiple moin fast cgi instances runnings on PORTS
]]><![CDATA[
NAME="moin"
DIR="/www/org.mywiki/bin"
FCGIAPP="./moin.fcg"
PREFIX="/usr/local"
]]><![CDATA[
# List of ports to start moin instances on, separated with whitesapce
# Keep in sync with fastcgi.server in lighttpd.conf
PORTS="1080 1081"
]]><![CDATA[
start_on_port () {
    # Start moin instance on port, leaving pid file
    port=$1
    
    cd "${DIR}" && sudo -u www "${PREFIX}/bin/spawn-fcgi" \
        -f "${FCGIAPP}" \
        -p $port \
        -P "${NAME}-${port}.pid" \
        > /dev/null
}
]]><![CDATA[
kill_on_port () {
    # Try to kill process using pid in pid file, then remove the pid file
    pidFile="${DIR}/${NAME}-$1.pid"
    kill `cat "$pidFile"` && rm -f "$pidFile" > /dev/null 
}
]]><![CDATA[
start () {
    for port in $PORTS; do start_on_port $port; done 
}
]]><![CDATA[
stop () {
    for port in $PORTS; do kill_on_port $port; done
}
]]><![CDATA[
case "$1" in
start)
    # XXX starting twice will break pid files (bug in spawn-fcgi)
    start && echo -n " $NAME"
        ;;
stop)
        stop && echo -n " $NAME"
        ;;
restart)
    stop
    start && echo -n " $NAME"
        ;;
*)
        echo "Usage: `basename $0` {start|stop|restart}" >&2
        ;;
esac
]]><![CDATA[
exit 0]]></screen></section><section><title>Mac OS X: Adding MoinMoin startup script</title><para>With this script, moin instances will be started automatically on startup. </para><orderedlist numeration="arabic"><listitem><para>Install <ulink url="http://darwinports.opendarwin.org/getdp/">darwinports</ulink> </para></listitem><listitem><para>Install DarwinPortsStartup package: </para><screen><![CDATA[sudo port install DarwinPortsStartup]]></screen></listitem><listitem><para>Copy moin.sh into <code>/opt/local/etc/rc.d</code>: </para><screen><![CDATA[sudo cp moin.sh /opt/local/etc/rc.d]]></screen></listitem></orderedlist></section></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="modpy-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheWithModPython">mod_python Setup using Apache</ulink></title><section><title>Why Use mod_python</title><para><ulink url="http://modpython.org/">mod_python</ulink> embeds the python interpreter into the apache server. This saves initialization time and the need of forking cgi scripts. It doesn't have the ability to run as different users. It will always run as the main apache user and group. Be sure that your wiki data files are accessible and writable by your apache server. </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/attention.png" width="16"/></imageobject><textobject><phrase>&lt;!&gt;</phrase></textobject></inlinemediaobject> The basic configuration is suitable for mod_python 3.1.3 and later. If you use older version, see the section &quot;Older mod_python versions&quot; </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/attention.png" width="16"/></imageobject><textobject><phrase>&lt;!&gt;</phrase></textobject></inlinemediaobject> mod_python will cause your apache processes to increase their memory requirements considerably - especially as apache runs many separate processes which will each need to have their own copy of the python code and data in the process memory space.  You may find that FastCGI, as detailed in <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/FastCgi#">HelpOnInstalling/FastCgi</ulink> is rather more efficient in this respect. </para></section><section><title>Basic configuring</title><orderedlist numeration="arabic"><listitem><para>Install mod_python </para></listitem><listitem><para>Set up a wiki instance </para></listitem><listitem><para>Edit <code>wikiconfig.py</code> </para></listitem><listitem><para>Changes to Apache <code>httpd.conf</code> </para></listitem><listitem><para>Restart Apache </para></listitem></orderedlist><para>The sample configurations below are for a wiki instance called <code>mywiki</code> installed in a directory <code>/var/www/moin/mywiki</code> with the main <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> installation installed in python's default site library path. The wiki appears as URL <code>/mywiki</code> under the server - ie <code>http://my.ser.ver/mywiki</code>.  You will need to change these to reflect your installation. </para><section><title>Install mod_python</title><para>Most people will just add a <code>mod_python</code> package to their current operating system installation.  If you are building from source then you should consult the <ulink url="http://modpython.org/live/current/doc-html/">mod_python documentation</ulink>. </para><para>The mod_python installation should have added some lines to the Apache configuration file - either in the file itself or in an included configuration file (for example on Red Hat or Fedora linux the mod_python configuration is in <code>/etc/httpd/conf.d/python.conf</code>). </para><para>Make sure you have this line in <code>httpd.conf</code> or mod_python will not work: </para><screen><![CDATA[LoadModule python_module modules/mod_python.so]]></screen><para>After this restart Apache and make sure that it starts successfully, and that the error log has a line similar to this:- </para><screen><![CDATA[[Sat Jan 01 15:40:49 2005] [notice] mod_python: Creating 4 session mutexes based on 150 max processes and 0 max threads.]]></screen><para>You may need to change some environment variables on (eg) FreeBSD - this is detailed in the port installation message. </para></section><section><title>Set up a wiki instance</title><para>This is done as shown in <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">WikiInstanceCreation</ulink>. Its recommended to first configure the wiki with cgi and check that it works, then change the configuratin to use mod_python. This allows you be sure that any problems are in the mod_python transition rather than the basic <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> installation. </para><orderedlist numeration="arabic"><listitem><para>Copy moin.cgi into your wiki directory </para></listitem><listitem><para>Configure <code>httpd.conf</code> as cgi first (the shown Alias is for moin version 1.6.0): </para><itemizedlist><listitem override="none"><screen><![CDATA[Alias /moin_static160/ "/usr/share/moin/htdocs/"
ScriptAlias /mywiki "/var/www/moin/mywiki/moin.cgi"]]></screen></listitem></itemizedlist></listitem></orderedlist><para>Restart Apache and make test that your wiki works. </para></section><section><title>Edit `wikiconfig.py`</title><para>Make sure you use only absolute paths - relative paths will not work! </para><screen><![CDATA[data_dir = '/var/www/moin/mywiki/data/'
data_underlay_dir = '/var/www/moin/mywiki/underlay/']]></screen><para>If you do not want to use absolute paths, you can use Python's os module to construct the relative paths: {{{import os data_dir = os.path.join(os.path.dirname(<emphasis role="underline">file</emphasis>), 'data/') data_underlay_dir = os.path.join(os.path.dirname(<emphasis role="underline">file</emphasis>), 'underlay/') }}} </para><para>Test that the wiki works after this change. </para></section><section><title>Changes to Apache `httpd.conf`</title><para>After your wiki is running as cgi script, convert it to run with mod_python.  </para><para>If you run your wiki as cgi as we recommended before, remove or comment the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/ScriptAlias#">ScriptAlias</ulink> directive: </para><screen><![CDATA[#ScriptAlias /mywiki "/var/www/moin/mywiki/moin.cgi"]]></screen><para>Add a <code>Location</code> directive: </para><screen><![CDATA[<Location /mywiki>
    SetHandler python-program
    # Add the path of your wiki directory
    PythonPath "['/var/www/moin/mywiki'] + sys.path"
    PythonHandler MoinMoin.request.request_modpython::Request.run
</Location>]]></screen><para>If you have multiple <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> instances then add one location directive for each one (changing the paths as appropriate) and add a line with the directive <code>PythonInterpreter mywiki</code> to each Location section. With this directive different subinterpreters with completely separate namespaces will be used for each wiki (see <ulink url="http://modpython.org/live/current/doc-html/pyapi-interps.html">here</ulink> for details). </para><para>If you did not install <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> in the default location, you will have to add the path to <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> to the system path: </para><screen><![CDATA[    PythonPath "['/var/www/moin/mywiki', '/prefix/lib/python2.x/site-packages'] + sys.path"]]></screen><para>Restart Apache - everything should now work correctly. </para></section></section><section><title>Solving problems for non-root-mounted wikis</title><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> If your wiki does not have a root URL (like <code>http://www.example.com/FrontPage</code>), then you might need to follow the next steps: </para></listitem></itemizedlist><para>On some installations, mod_python hands <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> incorrect script_name and path_info. It usually happens when using the Apache Location directive, with a wiki in an arbitary path: </para><screen><![CDATA[<Location /farm/mywiki>
    ...
</Location>]]></screen><para>This will not work, because its not clear what is the script name, since with location setup, there is no real script. </para><para>To solve this problem, use a <code>PythonOption</code> directive: </para><screen><![CDATA[<Location /farm/mywiki>
    # Location value must match the Apache Location value!
    PythonOption Location /farm/mywiki
    ...
</Location>]]></screen></section><section><title>Configuring root wiki</title><para>You may wish to have your wiki appearing at the root of your webserver - for example so that <code>http://wiki.example.com/</code> will map to your wiki rather than having to use <code>http://wiki.example.com/mywiki/</code>.  This requires a slightly different form of configuration using <code>mod_rewrite</code> - this is a standard module of recent Apache distributions, and is often enabled by default. </para><para>You need to set up your wiki instance as described above, and also copy <code>moinmodpy.py</code> from the Moin installation directory to the wiki instance directory (<code>/var/www/moin/mywiki</code> in these examples). </para><para>The Apache configuration needs <code>mod_rewrite</code> enabled - so the line </para><screen><![CDATA[LoadModule rewrite_module modules/mod_rewrite.so]]></screen><para>should appear in the first part of the <code>httpd.conf</code> configuration file. </para><para>The wiki and virtual host configuration should look like this (Alias is for moin version 1.6.0):- </para><screen><![CDATA[<VirtualHost *:80>
  ServerAdmin postmaster@example.com
  DocumentRoot /var/www/html
  ServerName wiki.example.com
  Alias /moin_static160/ "/usr/share/moin/htdocs/"
]]><![CDATA[
  # Rewrite urls
  RewriteEngine On
  RewriteLogLevel 0
  # map /wiki static files to Moin htdocs
  RewriteRule ^/moin_static160/(.*)$ /usr/share/moin/htdocs/$1 [last]
  RewriteRule ^/robots.txt$ /usr/share/moin/htdocs/robots.txt [last]
  RewriteRule ^/favicon.ico$ /usr/share/moin/htdocs/favicon.ico [last]
  # map everything else to server script
  RewriteRule ^(.*)$ /var/www/moin/mywiki/moinmodpy.py$1
]]><![CDATA[
  <Directory "/var/www/moin/testwiki">
    # Modpy stuff
    AddHandler python-program .py
    # Add the path to the wiki directory, where
    # moinmodpy.py and wikiconfig.py are located.
    PythonPath "['/var/www/moin/mywiki'] + sys.path"
    PythonHandler MoinMoin.request.request_modpython::Request.run
  </Directory>
</VirtualHost>]]></screen><para>Apache should be restarted, and the FrontPage of <code>mywiki</code> should now appear at <code>http://wiki.example.com/</code>. </para><para>Other ways of handling root level wikis with Apache are detailed in the appropriately named <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnConfiguration/ApacheVoodoo#">HelpOnConfiguration/ApacheVoodoo</ulink>. </para></section><section><title>Older mod_python versions</title><para>mod_python versions 2.7.10, 3.0.4 and 3.1.2b have a bug in <code>apache.resolve_object</code>. This bug was reported to the mod_python maintainers and has been fixed in the 3.1.3 release. The best fix for this is to update to the current release. However if you are unable to do this there are 2 possible solutions: </para><section><title>Use a wrapper script</title><para><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> come with a <code>moinmodpy.py</code> wrapper script, and this could be used by changing the <code>PythonPath</code> and <code>PythonHandler</code> directives as shown in the <code>moinmodpy.htaccess</code> file.  </para></section><section><title>Fix mod_python</title><para>mod_python has a small resolver bug in versions 2.7.10, 3.0.4 and 3.1.2b. The method <code>resolve_object</code> in <code>mod_python/apache.py</code> checks the wrong object, and so the lookup for <code>RequestModPy.run</code> fails. </para><para>To fix it you need to change the method <code>resolve_object</code> (around line 551 for mod_python 3.1.2b) from </para><screen><![CDATA[        if silent and not hasattr(module, obj_str):
            return None]]></screen><para>to </para><screen><![CDATA[        if silent and not hasattr(obj, obj_str):
            return None]]></screen></section></section><section><title>Troubleshooting</title><para>Page access gives apache error:: </para><itemizedlist><listitem override="none"><para><code>PythonHandler MoinMoin.request::RequestModPy.run: OSError: [Errno 2] No such file or directory: 'data/user'</code> This appears to be caused by you not having an absolute path for <code>data_dir</code> in <code>moin_config.py</code>.  There are several other lines of error traceback preceding this one in the apache error log.  Fix the path in <code>moin_config.py</code>. </para></listitem></itemizedlist></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="twisted-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/TwistedWeb">Setup using Twisted</ulink></title><section><title>Using MoinMoin with Twisted</title><para><ulink url="http://twistedmatrix.com/trac/wiki">Twisted</ulink> is an event-driven networking framework for many kinds of applications. For <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> Twisted is used as a web server that just imports <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink> persistently. This has the advantage that the Python interpreter and all Python scripts (including Twisted itself and also <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink>) is only loaded and initialized one time, and that data can be cached in memory from request to request, enhancing the performance of <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink>. </para><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> First do <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink> and <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink>. </para></listitem></itemizedlist><para>Besides the general installation you need 3 files:  </para><orderedlist numeration="arabic"><listitem><para>the script <code>/path/to/cgi-dir/mointwisted</code> (see &quot;Starting the server&quot; below) </para></listitem><listitem><para>the webserver script file like <code>mointwisted.py</code> (which needs to be in the same directory where your working directory is). </para></listitem><listitem><para>the configuration file like  <code>/path/to/wikiconfig-dir/wikiconfig.py</code> </para></listitem></orderedlist><section><title>Install Twisted</title><para>First, install Twisted (see URL above). Many Linux distributions have Twisted packages. Please refer to the documentation of Twisted for installation information. </para></section><section><title>Configuring the Twisted server</title><para>Copy the file <code>wiki/server/mointwisted.py</code> to your wiki directory. Edit and adapt the settings to your needs. </para><section><title>System path configuration</title><para>If you did a standard install, and you are not a developer, you probably want to skip this section. Otherwise, you might want to add the path to moin and config file, like that: </para><screen><![CDATA[sys.path.insert(0, '/path/to/moin')
sys.path.insert(0, '/path/to/wikiconfig')]]></screen></section><section><title>Config class options</title><para>If you did a standard install, the default options might be just what you need. Check and change what you like: </para><informaltable><tgroup cols="3"><colspec colname="col_0"/><colspec colname="col_1"/><colspec colname="col_2"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Option</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Default</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Comment</emphasis> </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> docs </para></entry><entry colsep="1" rowsep="1"><para> '/usr/share/moin/wiki/htdocs' </para></entry><entry colsep="1" rowsep="1"><para> Path to moin shared files </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> user </para></entry><entry colsep="1" rowsep="1"><para> 'www-data' </para></entry><entry colsep="1" rowsep="1"><para> If you run as root, the server will run as this user </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> group </para></entry><entry colsep="1" rowsep="1"><para> 'www-data' </para></entry><entry colsep="1" rowsep="1"><para> If you run as root, the server will run as this group </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> port </para></entry><entry colsep="1" rowsep="1"><para> 8080 </para></entry><entry colsep="1" rowsep="1"><para> Port to serve. To serve a privileged port below 1024 you will have to run as root </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> interfaces </para></entry><entry colsep="1" rowsep="1"><para> <code>['']</code> </para></entry><entry colsep="1" rowsep="1"><para> A list of interfaces the server will listen to. If the list contains the entry <code>''</code> (like for the default configuration), all other entries are ignored and the server will listen to all interfaces. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> logPath </para></entry><entry colsep="1" rowsep="1"><para> 'mointwisted.log' </para></entry><entry colsep="1" rowsep="1"><para> Log file. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> profiler </para></entry><entry colsep="1" rowsep="1"><para> commented python code </para></entry><entry colsep="1" rowsep="1"><para> Useful only if you are a moin developer. </para></entry></row></tbody></tgroup></informaltable></section></section><section><title>Configuring wikiconfig.py</title><para>The sample config file should be just fine. </para><para>Don't change <code>url_prefix_static</code> as the default value is hardcoded in the Twisted server. </para></section><section><title>Starting the server</title><section><title>on Unix</title><para>On GNU/Linux, Mac OS X or another POSIX-like OS, copy <code>wiki/server/mointwisted</code> to your wiki directory. You might want to adapt <code>PYTHONPATH</code> and the path to <code>twistd</code>.  </para><para>Start the server with <code>./mointwisted start</code> and test your wiki at <ulink url="http://localhost:8080/"/>. Stop the server with <code>./mointwisted stop</code>. </para><para>For more options run <code>./mointwisted</code> without arguments. </para><para>If you want to start the server via initscript make sure <code>mointwisted</code> finds <code>montwisted.py</code> on startup!  </para></section><section><title>on Windows</title><para>Copy <code>wiki/server/mointwisted.cmd</code> to your wiki directory. You might have to change the path pointing to the python-scripts directory. </para><para>Double click <code>mointwisted.cmd</code> to start the server. It will create a new terminal window. To stop the server, close the terminal window. </para></section></section></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="linuxstandalone-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/StandaloneServer">Linux Installation using standalone server</ulink></title><para><emphasis role="strong">Installing and configuring standalone server</emphasis> </para><para>See also: <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnConfiguration/IntegratingWithApache#">HelpOnConfiguration/IntegratingWithApache</ulink> </para><para>The standalone server is especially made for local wikis because it does not need a web server installed. Only Python and Moin are necessary! </para><section><title>The quick way</title><para>See <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/DesktopEdition#">DesktopEdition</ulink>. </para></section><section><title>The flexible way</title><para>Instead of just running it like described above, you can of course move stuff to different places (see <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink>, <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink>). </para><para>You can then invoke the moin standalone server using the <code>moin</code> scripting command: </para><screen><![CDATA[# for details and other options, see: moin server standalone --help
moin --config-dir=/etc/moin server standalone --docs=/usr/share/moin/htdocs]]></screen><para>Of course you have to give correct values that match your setup: </para><itemizedlist><listitem><para><code>--config-dir</code> gives the directory that contains your wikiconfig (or farmconfig). </para><itemizedlist><listitem><para>wikiconfig points to other important pathes, e.g. <code>data_dir</code> and <code>underlay_dir</code> </para></listitem></itemizedlist></listitem><listitem><para><code>--docs</code> gives the directory where moin finds the static files (css, imgs, etc.) </para></listitem></itemizedlist><para>If it does not find the <code>moin</code> command: </para><itemizedlist><listitem><para>if you used <code>setup.py</code> it should have copied it to <code>/usr(/local)/bin</code> - check your PATH. </para></listitem><listitem><para>if you don't want to use <code>setup.py</code> just write your own <code>moin</code> command script: </para><screen><![CDATA[#Fix and uncomment those 2 lines if it doesn't find the MoinMoin package:
#import sys
#sys.path.insert(0, '/path/to/moin_code')
from MoinMoin.script.moin import run
run()]]></screen></listitem></itemizedlist><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/idea.png" width="16"/></imageobject><textobject><phrase>(!)</phrase></textobject></inlinemediaobject> If it crashes and tells it can't import <code>MoinMoin</code>, then just uncomment and fix the <code>sys.path</code> stuff you see above. </para><para>Now point your browser at <code>http://localhost:8080/</code> (or whatever moin tells you). </para><para>If you want to run the moin process as a daemon, have a look at the <code>--start</code>, <code>--stop</code> and <code>--pidfile</code> options. </para><section><title>Serving port 80 on Unix</title><para>On GNU/Linux, Mac OS X or other Posix like OS, you can serve the standard port 80 used for web serving, but you must start moin as <code>root</code> for this. </para><para>Set <code>port</code> to 80, and verify that <code>user</code> and <code>group</code> exists on your system. If not, set them to an existing user, meant for web serving. If needed, <code>chown</code> your wiki dir to this user and group. </para></section><section><title>Standalone Server configuration</title><para>Alternatively to giving parameters by commandline options, you can also have a <code>wikiserverconfig.py</code> and specify your stuff in a <code>Config</code> class there. See the example file in the toplevel directory. </para><informaltable><tgroup cols="3"><colspec colname="col_0"/><colspec colname="col_1"/><colspec colname="col_2"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Option</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Default</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Comment</emphasis> </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> name </para></entry><entry colsep="1" rowsep="1"><para> <code>'moin'</code> </para></entry><entry colsep="1" rowsep="1"><para> Server name, used by default for log and pid files. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> docs </para></entry><entry colsep="1" rowsep="1"><para> <code>'/usr/share/moin/wiki/htdocs'</code> </para></entry><entry colsep="1" rowsep="1"><para> Path to moin shared files. If you used <code>--prefix</code> install, the default path will not work, and you must set the path to <code>'PREFIX/share/moin/wiki/htdocs'</code>. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> user </para></entry><entry colsep="1" rowsep="1"><para> <code>'www-data'</code> </para></entry><entry colsep="1" rowsep="1"><para> If you run as root, the server will run with as this user </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> group </para></entry><entry colsep="1" rowsep="1"><para> <code>'www-data'</code> </para></entry><entry colsep="1" rowsep="1"><para> If you run as root, the server will run with as this group </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> port </para></entry><entry colsep="1" rowsep="1"><para> <code>8000</code> </para></entry><entry colsep="1" rowsep="1"><para> Port to serve. To serve privileged port under 1024 you will have to run as root </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> interface </para></entry><entry colsep="1" rowsep="1"><para> <code>'localhost'</code> </para></entry><entry colsep="1" rowsep="1"><para> The interface the server will listen to. The default will listen only to localhost. Set to <code>''</code> to listen to all.</para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> serverClass </para></entry><entry colsep="1" rowsep="1"><para> <code>'ThreadPoolServer'</code>, <code>'ThreadingServer'</code>, <code>'ForkingServer'</code>, <code>'SimpleServer'</code>, <code>'SecureThreadPoolServer'</code> </para></entry><entry colsep="1" rowsep="1"><para> The server type to use, see the comments in the <code>moin.py</code>. The default is <code>'ThreadPoolServer'</code>, which create a pool of threads and reuse them for new connections. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> threadLimit </para></entry><entry colsep="1" rowsep="1"><para> <code>10</code> </para></entry><entry colsep="1" rowsep="1"><para> How many threads to create. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> requestQueueSize </para></entry><entry colsep="1" rowsep="1"><para> <code>50</code> </para></entry><entry colsep="1" rowsep="1"><para> The count of socket connection requests that are buffered by the operating system. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> properties </para></entry><entry colsep="1" rowsep="1"><para> <code> {} </code> </para></entry><entry colsep="1" rowsep="1"><para> allow overriding any request property by setting the value in this dict e.g <code>properties = {'script_name': '/mywiki'</code>}. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> ssl_privkey </para></entry><entry colsep="1" rowsep="1"><para> <code> None </code> </para></entry><entry colsep="1" rowsep="1"><para> If using the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/SecureThreadPoolServer#">SecureThreadPoolServer</ulink>, this must point to the server's private key. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> ssl_certificate </para></entry><entry colsep="1" rowsep="1"><para> <code> None </code> </para></entry><entry colsep="1" rowsep="1"><para> If using the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/SecureThreadPoolServer#">SecureThreadPoolServer</ulink>, this must point to the server's certificate. </para></entry></row></tbody></tgroup></informaltable><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/idea.png" width="16"/></imageobject><textobject><phrase>(!)</phrase></textobject></inlinemediaobject> There may be more options useful to moin developers, see the comments in <code>moin.py</code> </para></listitem></itemizedlist></section><section><title>Configuring wikiconfig.py</title><para>The sample config file should be just fine. </para><para>The default value of <code>url_prefix_static</code> is hardcoded into the standalone server script, do not change it or it won't work! </para></section><section><title>Using the secure standalone server</title><para>The standalone server supports SSL when using the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/SecureThreadPoolServer#">SecureThreadPoolServer</ulink> server class. The SSL support is provided by the <ulink url="http://trevp.net/tlslite/">TLSLite library</ulink>. <emphasis role="strong">All wiki traffic is forced to SSL when using the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/SecureThreadPoolServer#">SecureThreadPoolServer</ulink></emphasis>.  </para><para>Two additional configuration options are required when using the <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/SecureThreadPoolServer#">SecureThreadPoolServer</ulink>. First, <code>ssl_privkey</code> must point to the server's private key. Second, <code>ssl_certificate</code> must point to the server's certificate.  </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> <emphasis>TLSLite does not support a password protected private key unless additional libraries are used. Consult the TLSLite webpage for more information.</emphasis> </para><para>Typically a certificate would be purchased from an certificate authority, such as Thawte (<ulink url="http://www.thawte.com"/>). However, since the suggested usage of the standalone server is for personal use, a self signed certificate may be appropriate. For more information on how to generate a server private key, and a self signed certificate, see the <ulink url="http://www.openssl.org/docs/HOWTO/">openssl HOWTO pages</ulink>. </para><para>For example, to create the server's private key, run the following: </para><para><code>openssl genrsa -out privkey.pem 2048</code> </para><para>To create a self signed certificate for the newly created private key, run the following: </para><para><code>openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095</code> </para><para>moin.py then needs to be told about the generated files <code>privkey.pem</code> and <code>cacert.pem</code>. For the example above, the following lines would need to be added to moin.py: </para><screen><![CDATA[    ssl_privkey = "/secure/path/to/privkey.pem"
    ssl_certificate = "/secure/path/to/cacert.pem"]]></screen><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> Using a self signed certificate will cause your browser to generate a warning that it cannot verify the identify of the wiki server. This is because the certificate was not signed by a recognized certificate authority (CA). In order to get rid of this warning, you must purchase a certificate from a CA. </para></section></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="macosx-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnMacOsx">Mac OS X Installation using Apache</ulink></title>&lt;&lt;Include: execution failed ['NoneType' object has no attribute 'nodeName'] (see also the log)&gt;&gt;<!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="win32apache-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnWin32">Windows Installation using Apache</ulink></title><itemizedlist><listitem override="none"/></itemizedlist><section><title>System Requirements &amp; Preparation</title><para>Before you install MoinMoin, you must have the necessary infrastructure in place. This procedure explains the steps necessary to install the infrastructure and provides detailed instructions for the installation of MoinMoin. </para><itemizedlist><listitem><para><emphasis role="strong">Windows 2000, XP, or greater </emphasis>(including server variants, such as Windows 2000 Server). </para><itemizedlist><listitem><para>Earlier versions of Windows (such as Win98 or WinME) are <emphasis role="underline"><emphasis>not</emphasis></emphasis> recommended due to their obsolete and poor-performing multiple-process handling. WinNT is obsolete and Microsoft has officially dropped support for it and should not be considered a safe server platform for the Internet. </para></listitem><listitem><para>Run Windows Update to ensure that you are running the latest service packs and security patches. </para></listitem><listitem><para>Apache doesn't require Windows Server (unlike IIS), so it's a great way to use an older desktop without using a Server license! Apache doesn't artificially limit the number of connections, unlike personal IIS for example. </para></listitem></itemizedlist></listitem></itemizedlist><para>Many users prefer to install software products in a folder other than the installation default. Python typically changes the default installation folder name with each point release, and Apache has changed the default installation folder name with the release of version 2.  Instead of enumerating all the possibilities at each step, this procedure will use the <emphasis role="strong">Reference</emphasis> name in the table below as the installed location for each product. Substitute your real installation location when editing configuration files and entering commands. </para><informaltable><tgroup cols="3"><colspec colname="col_0"/><colspec colname="col_1"/><colspec colname="col_2"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Reference </para></entry><entry colsep="1" rowsep="1"><para>Product </para></entry><entry colsep="1" rowsep="1"><para>Installation Default or Typical Name </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para><emphasis role="strong">C:\Apache</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> Apache </para></entry><entry colsep="1" rowsep="1"><para>C:\Program Files\Apache Group\Apache2 </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para><emphasis role="strong">C:\Python</emphasis> </para></entry><entry colsep="1" rowsep="1"><para>Python </para></entry><entry colsep="1" rowsep="1"><para>C:\Python24 </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para><emphasis role="strong">C:\Moin</emphasis> </para></entry><entry colsep="1" rowsep="1"><para>wiki instances </para></entry><entry colsep="1" rowsep="1"><para>C:\My Documents\Moin </para></entry></row></tbody></tgroup></informaltable><para>Downloading and installing all of the required components below will require almost 100 MB of disk space - shouldn't be a problem nowadays, right? </para></section><section><title>Installation</title><section><title>Installing Apache</title><orderedlist numeration="arabic"><listitem><para>Download &amp; Install Apache 2.0.xx or greater </para><orderedlist numeration="lowerroman"><listitem><para>Apache2 was re-written with better support for non-unix systems, therefore the 2.0.xx series is <emphasis>strongly</emphasis> recommended for Windows users over Apache 1.3.xx. </para></listitem><listitem><para>Go to <ulink url="http://httpd.apache.org"/> </para></listitem><listitem><para>download the <emphasis role="strong">Win32 Binary (MSI Installer)</emphasis> for the latest version of Apache 2. </para></listitem><listitem><para>Read the Apache documentation to determine the correct installation procedure for your situation. </para></listitem><listitem><para>Test your Apache installation to make sure it runs correctly before proceeding (questions and problems with the Apache installation should be resolved through the resources provided by the Apache organization). </para></listitem></orderedlist></listitem></orderedlist></section><section><title>Installing Python</title><para>There are currently two different distributions of Python available for Windows. </para><orderedlist numeration="arabic"><listitem><para>The normal Python distribution is available from <ulink url="http://www.python.org"/>. This is distributed as a windows executable (.exe) file. </para></listitem><listitem><para>An alternative distribution called <emphasis role="strong">ActivePython</emphasis> is available from <ulink url="http://www.activestate.com/"/>. This distribution uses the MSI Installer and contains some tools specific to the Windows operating system and a popular Windows IDE called Pythonwin, which may be useful <emphasis role="underline"><emphasis>if</emphasis></emphasis> you also plan to develop in Python.  ActivePython is available for free; an email address is requested (but not required) before downloading. </para></listitem></orderedlist><para>MoinMoin will work with either distribution, but requires Python release 2.3 or later.  Download and install the distribution of your choice.  Questions and problems dealing with the Python installation process should be resolved through the use of resources provided by Python.org or ActiveState.  Be sure your Python installation is correct before proceeding. </para></section><section><title>Installing MoinMoin</title><orderedlist numeration="arabic"><listitem><para><emphasis role="strong">Download MoinMoin</emphasis> </para><itemizedlist><listitem><para>The most current version is here: <ulink url="http://moinmoin.wikiwikiweb.de/MoinMoinDownload#">MoinMoinDownload</ulink> </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">Expand the archive</emphasis> </para><itemizedlist><listitem><para><emphasis role="underline"><emphasis>Note:</emphasis></emphasis> users of older versions of <ulink url="http://www.winzip.com">WinZip</ulink> report problem expanding .tar.gz files. Either upgrade or use the free <ulink url="http://7-zip.org/">7-Zip</ulink> utility. </para></listitem><listitem><para>Expand the archive into <code>C:\TEMP</code> or an alternative location. </para></listitem><listitem><para>You should then have a folder such as <code>C:\TEMP\moin-x.x</code> where &quot;x.x&quot; is the current release number. This folder will contain a <code>setup.py</code> file in addition to several other files and subfolders. </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">Run Setup.py from the commandline</emphasis> </para><itemizedlist><listitem><para>Open an DOS window (start &gt; Run... &gt; type <code>cmd</code>) and enter the commands:</para></listitem></itemizedlist><screen><![CDATA[C:
cd \TEMP\moin-x.x
C:\Python\python setup.py install --record=install.log]]></screen></listitem></orderedlist><para>The above commands will add MoinMoin to your <code>C:\Python</code> installation and create an <code>install.log</code> file in <code>C:\temp\moin-x.x</code> listing all the copied files. You can use Windows Explorer to examine the newly created folders within <code>C:\Python</code>. You should find a <code>C:\Python\share\moin</code> folder and a <code>C:\Python\Lib\site-packages\MoinMoin</code> folder. The <code>MoinMoin</code> folder contains many Python scripts and several subfolders. </para><para>You are now ready to create a wiki instance. </para></section></section><section><title>Configuration</title><para>It is a good practice to try to keep all of your personal or site specific data under a few root folders. This way you can easily backup your important data on a regular basis without having to waste time either backing up static files or picking out dozens of important folders scattered throughout your folder structure.  You should avoid placing your wiki data under the <code>C:\Python</code> folder so that you can later upgrade Python or MoinMoin without accidentally overwriting or deleting your wiki data.  For the same reason, you probably don't want to place your wiki data within the <code>C:\Apache</code> folder. </para><para>Choose a location appropriate for you; the following instructions assume you will be creating one or more wiki instances in <code>C:\Moin\</code> and the first wiki instance will be named <code>mywiki</code>. </para><para>You may replace the name <code>mywiki</code> with almost any name you wish, but do not use <code>wiki</code> because that is used by MoinMoin for loading standard images and style sheets. Although this can be changed later, the name you choose for <code>mywiki</code> will become part of the url used to access your site, e.g. <code>http://server.myorganization.org/mywiki/FrontPage</code>. </para><section><title>Creating a Wiki Instance</title><para>Start an DOS window and enter the commands below. This will create a clone of the MoinMoin wiki in the mywiki folder. </para><screen><![CDATA[cd C:\
md Moin
md Moin\mywiki
md Moin\mywiki\data
md Moin\mywiki\underlay
cd \Python\share\moin
xcopy data        C:\Moin\mywiki\data /E
xcopy underlay    C:\Moin\mywiki\underlay /E
copy  config\*.* C:\Moin\mywiki\*.*
copy  server\*.* C:\Moin\mywiki\*.*]]></screen><para>If your server is going to run multiple wikis, you need to create additional clones. Do the same commands again, but use mywiki2 instead of mywiki. </para></section><section><title>Configuring wikiconfig.py</title><para>Edit <code>C:\Moin\mywiki\wikiconfig.py</code> and at least change <code>sitename</code> to the name of your wiki: </para><screen><![CDATA[    sitename = 'My Wiki']]></screen><para>Additionally, set <code>data_dir</code> and <code>data_underlay_dir</code> to the absolute paths of the particular directories. Like here: </para><screen><![CDATA[    data_dir = r'C:\Moin\mywiki\data'
    data_underlay_dir = r'C:\Moin\mywiki\underlay']]></screen><para>For a public installation, you'll normally want to forbid some of the more dangerous actions. Add a line like this to <code>wikiconfig.py</code>: </para><screen><![CDATA[    actions_excluded = ['AttachFile', 'DeletePage', 'RenamePage', ]]]></screen><para>If you will <emphasis><emphasis role="strong">not</emphasis></emphasis> be running a Wiki farm (if you're not sure what this means, then you probably won't be), make sure to delete the <code>farmconfig.py</code> file from the <code>C:\Moin\mywiki</code> directory, or else <code>moin.cgi</code> will most likely give off various errors (including one about not being able to find a configuration file) and will ultimately fail to start up properly. </para><para>Additional configuration details can be found in <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnConfiguration#">HelpOnConfiguration</ulink>. </para></section><section><title>Configuring moin.cgi</title><para>Use your editor to edit the file <code>C:\Moin\mywiki\moin.cgi</code>.  Change the first line (the shebang statement) to point to your local Python executable program. Note the forward slashes -- Apache uses the Unix convention for folder separators. This tells Apache the <code>moin.cgi</code> file is an executable script that will be interpreted by a program to be loaded from <code>C:/Python/python</code>. </para><screen><![CDATA[ #! C:/Python/python]]></screen></section><section><title>Configuring Apache httpd.conf</title><para>The next step is to tell Apache that is has more work to do. Use your editor to append the following lines to <code>C:\Apache\conf\httpd.conf</code>. Note the presence and absence of trailing slashes, it is important to enter the lines exactly as shown below. </para><screen><![CDATA[Alias       /moin_static160/ "C:/Python/share/moin/htdocs/"
ScriptAlias /mywiki          "C:/Moin/mywiki/moin.cgi"]]></screen><para>The <emphasis role="strong">Alias</emphasis> line above instructs Apache to serve images, style sheets, etc. from the specified folders and subfolders. The <emphasis role="strong">ScriptAlias</emphasis> line is needed once for each wiki instance, so if you have multiple wikis, repeat the statement using mywiki2, mywiki3, etc. The ScriptAlias statement instructs Apache to execute scripts from the specified folder. See the Apache docs for a complete explanation. </para><para>Test your changes by restarting your Apache server and try to access your newborn wiki with the URL <code>http://127.0.0.1/mywiki</code>. You should see the FrontPage, try to edit and save it, and if that works, verify your edit is reflected on the RecentChanges page. </para><para>And now, it is up to you and your user community to transform your wiki into an informative and useful tool. You will probably want to retain most of the HelpOn~ pages dealing with editing, delete those pages with irrelevant information (like this page, don't let your users or boss know how easy it was to install MoinMoin <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/smile4.png" width="16"/></imageobject><textobject><phrase>;-)</phrase></textobject></inlinemediaobject> ), and rewrite the FrontPage to introduce your wiki topic. </para></section></section><section><title>Troubleshooting</title><para>The first place to look for clues when the unexpected happens is to try changing your url to: <code>http://127.0.0.1/mywiki?action=test</code>. If Apache can find and execute the module <code>C:/Moin/mywiki/moin.cgi</code>, a page of diagnostics titled <emphasis role="strong">MoinMoin CGI Diagnosis</emphasis> will be displayed. Check the output for error messages. </para><para>The second place to look for is <code>C:\Apache\logs\error.log</code>. The following are common errors grouped by the message displayed by your browser: </para><itemizedlist><listitem><para><emphasis role="strong">Internal Server Error</emphasis> </para><itemizedlist><listitem><para>If the Apache log shows a message &quot;The system cannot find the file specified.&quot; then a possibility is the shebang statement in <code>moin.cgi</code> is incorrect. </para></listitem><listitem><para>If the Apache log shows a different error message, then the MoinMoin Python scripts may be abending. To determine the cause, you could try temporarily renaming <code>moin.cgi</code> to <code>moin.py</code>, loading <code>moin.py</code> with the Python <emphasis role="strong">idle</emphasis> IDE and executing it to determine if there are any error messages. </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">Not Found</emphasis> </para><itemizedlist><listitem><para>If the Apache error log shows the message &quot;File does not exist: C:/Apache/htdocs/mywiki&quot;,  the <emphasis role="strong">ScriptAlias</emphasis> statement in <code>httpd.conf</code> may be incorrect. </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">The Page Cannot be found</emphasis> </para><itemizedlist><listitem><para>If the Apache error log shows the message &quot;File does not exist: C:/Apache/htdocs/????&quot;, you may have mistyped the url &quot;<ulink url="http://127.0.0.1/mywiki"/>&quot; into your browser. </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">FrontPage Loads Without Icons</emphasis> </para><itemizedlist><listitem><para>If the Apache Error log shows many error messages &quot;File does not exist: C:/Apache/htdocs/wiki&quot;, then the <emphasis role="strong">Alias</emphasis> statement in <code>httpd.conf</code> may be incorrect. </para></listitem></itemizedlist></listitem><listitem><para>If you did not install MoinMoin in the Python site-packages folder (i.e. only if you deviated from the above instructions), you will have to activate the lines which add a folder to the sys.path and enter your path to MoinMoin there:</para><screen><![CDATA[import sys
sys.path.insert(0, r'C:\Moin\...')]]></screen></listitem></itemizedlist></section><section><title>Next Steps</title><section><title>Authenticating MoinMoin Users Against a Domain Controller</title><itemizedlist><listitem override="none"><para>Many organizations are setting up wiki's for documentation on their internal network.  As a result, many organizations require the security of authentication, which protects their content, as well as allowing people to work remotely on the wiki without anonymous eye's peeking at their site.  Domain authentication is convenient for both the administrator and the user, because it uses the same password the user would use for other network logins.  If this describes you, proceed to: </para></listitem><listitem override="none"><para><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnWin32withDomainAuthentication#">../ApacheOnWin32withDomainAuthentication</ulink> </para></listitem></itemizedlist></section><section><title>Simple Windows MoinMoin Backup</title><itemizedlist><listitem override="none"><para>Simple strategy for backing up your wiki: </para></listitem><listitem override="none"><para><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/Win32MoinEasyBackup#">../Win32MoinEasyBackup</ulink> </para></listitem></itemizedlist></section><section><title>FastCGI with Windows</title><itemizedlist><listitem override="none"><para>Dramatically increase performance of your wiki with the FastCGI Apache module: </para></listitem><listitem override="none"><para><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/ApacheOnWin32withFastCgi#">../ApacheOnWin32withFastCgi</ulink> </para></listitem></itemizedlist></section></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="win32iis-install"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/InternetInformationServer">Windows Installation using IIS</ulink></title><para><emphasis role="strong">Index</emphasis> <!--The macro TableOfContents doesn't work with the DocBook formatter.--> </para><section><title>Requirements &amp; Preparation</title><para>Before you install <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/MoinMoin#">MoinMoin</ulink>, make sure you have the necessary infrastructure in place, namely the <emphasis>Internet Information Services</emphasis> webserver (any version should be OK), and a <emphasis>Python</emphasis> installation (at least version 2.3 is required, the latest python release is recommended). </para><para>These instructions make the basic assumption that you will have these components installed in their default locations. In reality, you'll probably have them installed elsewhere (on the D: drive, for example). Be careful to substitute your drive and paths based on the following assumed default locations: </para><itemizedlist><listitem><para>IIS to its default location </para></listitem><listitem><para><code>C:\Python</code> - the Python interpreter </para></listitem><listitem><para><code>C:\Moin</code> - MoinMoin itself </para></listitem></itemizedlist></section><section><title>Installation</title><section><title>Installing IIS</title><para>From Microsoft: (<ulink url="http://www.microsoft.com/windows2000/en/server/iis/"/>) </para><orderedlist numeration="arabic"><listitem><para>To install IIS, add components, or remove components: </para><orderedlist numeration="lowerroman"><listitem><para>Click Start =&gt; Settings =&gt; Control Panel =&gt; Add/Remove Programs. </para></listitem><listitem><para>Click 'Add/Remove Windows Components', Check 'Internet Information Services' and follow the on-screen instructions to install. ( <inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> it is also recommended to click the 'details' button and un-selecting components you will not need. This will depend on your server role; but for example, you probably will not need FTP, or &quot;Frontpage 2000 Server Extensions&quot;). </para></listitem></orderedlist></listitem></orderedlist><para>Make sure that your webserver runs without problems before you start to install MoinMoin; problems with your webserver installation are not in the scope of this document. </para></section><section><title>Installing Python</title><para>There are currently two different distributions of Python available for Windows. Either version will work fine. </para><orderedlist numeration="arabic"><listitem><para><ulink url="http://www.python.org"/> - The standard open-source Python distribution. </para><itemizedlist><listitem><para>The installer is a windows executable (.exe) file. </para></listitem></itemizedlist></listitem><listitem><para><ulink url="http://www.activestate.com"/> - An alternative, commercially-supported, distribution (distributed for free (email address required)). </para><itemizedlist><listitem><para>The installer is a Windows .MSI file. </para></listitem><listitem><para>If you are or plan to develop in the Python language, ActivePython has some tools specific to the Windows operating system and includes a popular Windows IDE called Pythonwin. </para></listitem></itemizedlist></listitem></orderedlist><para>MoinMoin works with either distribution, but requires Python release 2.3 or later. Download and install the distribution of your choice. Be sure your Python installation is correct before proceeding. Installation is straightforward; however, any questions or issues regarding the Python installation process should be resolved through the use of resources provided by Python.org or ActiveState. </para></section><section><title>Installing MoinMoin</title><orderedlist numeration="arabic"><listitem><para><emphasis role="strong">Download MoinMoin</emphasis> </para><itemizedlist><listitem><para>The most current version is here: <ulink url="http://moinmoin.wikiwikiweb.de/MoinMoinDownload#">MoinMoinDownload</ulink> </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">Expand the archive</emphasis> </para><itemizedlist><listitem><para><emphasis role="underline"><emphasis>Note:</emphasis></emphasis> users of older versions of <ulink url="http://www.winzip.com">WinZip</ulink> report problem expanding .tar.gz files. Either upgrade or use the free <ulink url="http://7-zip.org/">7-Zip</ulink> utility. </para></listitem><listitem><para>Expand the archive into <code>C:\TEMP</code> or an alternative location. </para></listitem><listitem><para>You should then have a folder such as <code>C:\TEMP\moin-x.x</code> where &quot;x.x&quot; is the current release number. This folder will contain a <code>setup.py</code> file in addition to several other files and subfolders. </para></listitem></itemizedlist></listitem><listitem><para><emphasis role="strong">Run Setup.py from the commandline</emphasis> </para><itemizedlist><listitem><para>Open an DOS window (start &gt; Run... &gt; type <code>cmd</code>) and enter the commands:</para><screen><![CDATA[C:
cd \temp
unzip moin-1.6.zip
cd moin-1.6
python setup.py install --prefix=C:\Moin --record=install.log]]></screen></listitem></itemizedlist></listitem></orderedlist><para>This will install all necessary files to the &quot;<code>C:\Moin</code>&quot; directory, and create a &quot;<code>install.log</code>&quot; file listing all the files that are created there. </para><para>You are now ready to create a wiki instance. </para></section></section><section><title>Configuration</title><section><title>Creating a Wiki Instance</title><para>Enter these commands in a console window from C:\Moin&gt;: </para><screen><![CDATA[cd c:\Moin
md mywiki
md mywiki\data
md mywiki\underlay
xcopy share\moin\data mywiki\data /E
xcopy share\moin\underlay mywiki\underlay /E
copy share\moin\server\moin.cgi mywiki\
copy share\moin\config\wikiconfig.py mywiki\
copy share\moin\htdocs\index.html mywiki\default.htm]]></screen><para>&quot;<code>mywiki</code>&quot; is the name of your wiki instance, you might want to chose a different name best fitting the intended use of this instance; just don't name it simply &quot;<code>wiki</code>&quot;, because that would result in confusion and problems later on. </para><para>We have to make sure that <code>moin.cgi</code> can find the MoinMoin directory, so that &quot;<code>import MoinMoin</code>&quot; will work. The easiest way to make sure <code>MoinMoin</code> can be imported is to append to <code>sys.path</code> <emphasis>within</emphasis> <code>moin.cgi</code>. </para><para>You can change the first two lines of code in moin.cgi to something like this: </para><programlisting format="linespecific" language="python" linenumbering="numbered" startinglinenumber="1"><lineannotation><![CDATA[#!python]]></lineannotation>
<token><![CDATA[import]]></token><![CDATA[ ]]><methodname><![CDATA[sys]]></methodname>
<methodname><![CDATA[sys]]></methodname><![CDATA[.]]><methodname><![CDATA[path]]></methodname><![CDATA[.]]><methodname><![CDATA[append]]></methodname><![CDATA[(]]><phrase><![CDATA[']]></phrase><phrase><![CDATA[C:/Moin/Lib/site-packages]]></phrase><phrase><![CDATA[']]></phrase><![CDATA[)]]>
</programlisting><para>Notice that we're pointing to the directory which contains the MoinMoin directory, not the directory itself. </para></section><section><title>Configuring IIS</title><para>Next, you'll need to create two virtual directories in IIS. One for the shared data, and one for this specific wiki instance. </para><section><title>Configuring IIS 5.0 and above</title><orderedlist numeration="arabic"><listitem><para>Open <emphasis role="strong">Internet Services Manager</emphasis> (Start &gt; Settings &gt; Control Panels &gt; Administrative Tools &gt; ...). Open up the tree to <emphasis>Default Web Site</emphasis>. </para></listitem><listitem><para>Right click on <emphasis>Default Web Site</emphasis> and choose <emphasis>New &gt; Virtual directory</emphasis>. </para><orderedlist numeration="lowerroman"><listitem><para>This will bring up a wizard with the mandatory useless first screen, hit next. </para></listitem><listitem><para>Enter &quot;<code>wiki</code>&quot; for the alias name, hit next. </para></listitem><listitem><para>Browse to &quot;<code>C:\Moin\share\moin\htdocs</code>&quot;, hit next. </para></listitem><listitem><para>Leave the <emphasis>Access permissions</emphasis> at their defaults, hit next. </para></listitem><listitem><para>And now you're done, hit finish! </para></listitem></orderedlist></listitem><listitem><para>Now follow the same steps, but set the alias to &quot;<code>mywiki</code>&quot; and the path to &quot;<code>C:\Moin\mywiki</code>&quot;. </para></listitem><listitem><para>Use IIS Admin to remove permissions to read the data directory: </para><orderedlist numeration="lowerroman"><listitem><para>expand the &quot;<code>mywiki</code>&quot; node </para></listitem><listitem><para>right click on <code>data</code> </para></listitem><listitem><para>select <code>Properties</code> </para></listitem><listitem><para>and uncheck <code>Read</code>. </para></listitem><listitem><para>Repeat these steps with the <code>underlay</code> directory. </para></listitem></orderedlist></listitem><listitem><para>Now you need to setup the 'mywiki' alias so that it will run Python to interpret <code>.cgi</code> files. </para><orderedlist numeration="lowerroman"><listitem><para>On Windows Server 2003, click the <emphasis>Create</emphasis> button under <emphasis>Application Settings</emphasis> to create an application space. </para></listitem><listitem><para>Right-click on your new 'mywiki' alias and choose <emphasis>Properties</emphasis>. On the first tab (<emphasis>Virtual Directory</emphasis>), click the <emphasis>Configuration</emphasis> button. </para></listitem><listitem><para>The first tab is the <emphasis>App Mappings</emphasis> tab, which defines which programs to use for each file extension. </para></listitem><listitem><para>Click <emphasis>Add</emphasis>. Browse to your <code>python.exe</code> (probably something like <code>c:\pythonXX\python.exe</code>). </para></listitem><listitem><para>Then add <code>-u &quot;%s&quot; &quot;%s&quot;</code> after the Python executable path. The <emphasis>Executable</emphasis> line will look something like this: <code>&quot;C:\Python22\python.exe&quot; -u &quot;%s&quot; &quot;%s&quot;</code>. In the <emphasis>Extension</emphasis> box enter <code>.cgi</code> with the beginning period. </para></listitem><listitem><para>Make sure that the <emphasis>Check that file exists</emphasis> option is not checked (if it is, MoinMoin won't be able to display sub pages). </para></listitem><listitem><para>Ok, you're done with the alias configuration, click <emphasis>OK</emphasis> several times to get back out of all the dialog boxes. </para></listitem></orderedlist></listitem><listitem><para>If you add another wiki instance, you'll only need to setup the reference to its folder, they can safely share the &quot;<code>wiki</code>&quot; alias which points to static files only. </para></listitem></orderedlist></section><section><title>IIS 6.0 (Windows Server 2003)</title><para>The instructions below also apply to IIS 6.0 but the more aggressive security settings in newer version of IIS disallow the usage of <emphasis>unknown CGI extensions</emphasis>. That means you will always get a 404 error unless you do this: </para><orderedlist numeration="arabic"><listitem><para>Open <emphasis role="strong">IIS Manager</emphasis> (Start &gt; Programs &gt; Administrative Tools &gt; IIS Manager). </para></listitem><listitem><para>Go to the <emphasis role="strong">Web Service Extensions</emphasis> folder. </para></listitem><listitem><para>Under the <emphasis role="strong">Action</emphasis> menu, select <emphasis role="strong">Add a new Web service extension...</emphasis>. </para></listitem><listitem><para>For Extension name, give it a name such as <emphasis>.cgi</emphasis> or <emphasis>Python cgi</emphasis> or similar. </para></listitem><listitem><para>Under <emphasis role="strong">Required files</emphasis> click the <emphasis role="strong">Add...</emphasis> button and type in the exact command-line string you used above. Eg: <code>c:\python24\python.exe -u &quot;%s&quot; &quot;%s&quot;</code>, then click the <emphasis role="strong">Ok</emphasis> button. </para></listitem><listitem><para>Make sure the <emphasis role="strong">Set extension status to Allowed</emphasis> checkbox is checked and click the <emphasis role="strong">Ok</emphasis> button. </para></listitem></orderedlist><para>Another change that may be necessary if you are receiving HTTP Error 403 19 1314 while using IIS 6.0 is to adjust the Identity settings for the Application Pool that is being used by your site. The following steps assume you are adjusting the Default Web Site. </para><orderedlist numeration="arabic"><listitem><para>Open <emphasis role="strong">IIS Manager</emphasis> (Start &gt; Programs &gt; Administrative Tools &gt; IIS Manager). </para></listitem><listitem><para>Go to the <emphasis role="strong">Application Pool</emphasis> folder. </para></listitem><listitem><para>Select the Application Pool you wish to adjust. (likely <emphasis role="strong">DefaultAppPool</emphasis> ) When you do this on the right you will see the Application pools for each site on the server. This will include a Description (likely <emphasis role="strong">Default Application</emphasis> ) and a Path (<emphasis role="strong">&lt;Default Web Site&gt;</emphasis>). In this way you can be certain you are adjusting the appropriate Application Pool. </para></listitem><listitem><para>With <emphasis role="strong">DefaultAppPool</emphasis> still selected right click and select <emphasis role="strong">Properties</emphasis>. </para></listitem><listitem><para>Select the <emphasis role="strong">Identity</emphasis> tab and with <emphasis role="strong">Predefined</emphasis> clicked use the drop down box to change the <emphasis role="strong">Identity</emphasis> to <emphasis role="strong">Local System</emphasis> instead of Network Service. <emphasis>Please be aware that this is a workaround since you SHOULD set your group settings to allow Network Service to access the cgi scripts.</emphasis> </para></listitem></orderedlist><para>Under Windows Server 2003, you will also need to give your IUSR_MACHINENAME account <emphasis>Modify</emphasis> access to the mywiki\data and mywiki\underlay sub-directories, as file system permissions are more restricted by default than previous Windows versions. </para><para>That is all, try to access your new-born wiki with the URL <ulink url="http://127.0.0.1/mywiki/"/>. You should see the FrontPage, try to edit and save it, and if that works, see if your edit is reflected on the RecentChanges page. </para></section></section><section><title>Configuring wikiconfig.py</title><para>Finally, edit &quot;<code>wikiconfig.py</code>&quot; and at least change &quot;<code>sitename</code>&quot; and &quot;<code>logo_string</code>&quot; to some personal values: </para><screen><![CDATA[sitename = u'My Wiki'
logo_string = u'<img src="/mywiki/images/mywiki-logo.gif" alt="MyWiki Logo">My Wiki']]></screen><para>Where &quot;<code>images</code>&quot; is a directory under your &quot;<code>mywiki</code>&quot; instance. </para><para>NOTE: The configuration variable &quot;<code>url_prefix</code>&quot; in &quot;<code>wikiconfig.py</code>&quot; should match the alias for &quot;<code>C:\Moin\share\moin\htdocs</code>&quot; or themes will not work (&quot;<code>/wiki</code>&quot; for the instructions above). This way, any reference in &quot;<code>wikiconfig.py</code>&quot; to &quot;<code>/wiki/something</code>&quot; will look in the shared data directory and a reference to &quot;<code>/mywiki/something</code>&quot; will look in the wiki instance directory. These are considered absolute paths because relative paths will not work correctly. </para><para>It seems you need to change the Custom Errors setting for 404 before you can create new pages. You can accomplish this by performing the following steps: </para><orderedlist numeration="arabic"><listitem><para>Go into the IIS Manager, right-click on 'mywiki' (or whatever your wiki instance directory is called), and select properties. </para></listitem><listitem><para>Next, go to the Custom Errors tab and find the 404 entry, and click the <emphasis>Set to Default</emphasis> button. </para></listitem></orderedlist></section></section><section><title>Troubleshooting</title><itemizedlist><listitem><para>If you see an error like &quot;<code>ImportError: No module named MoinMoin</code>&quot;, it means that python cannot find MoinMoin. See above for how to add to <code>sys.path</code>. </para></listitem><listitem><para>If you see an error like Error 13: Permission Denied, it means that your web user permissions for the files do not have write/modify enabled. </para></listitem><listitem><para>If the page never loads after hitting <code>Save Changes</code>, you should check the permissions of the <code>data</code> directory. Make sure the IUSR_COMPUTERNAME user has modify permissions. </para></listitem><listitem><para>If some images like InterWiki and WorldWideWeb don't show up, it could have been because of incorrect permissions or a bad &quot;<code>url_prefix</code>&quot; in &quot;<code>wikiconfig.py</code>&quot; or the cached pages need to be updated by an Edit or deleting them in the data folder. Or you are using MS IE which has broken CSS :before support - try another browser. </para></listitem><listitem><para>If you see an error message like:</para><screen><![CDATA[Check your URL regular expressions in the "wikis" list in "farmconfig.py". Content-type: text/html;charset=utf-8
MoinMoin Configuration Error
Could not find a match for url: "servername/wikiname/moin.cgi?
Check your URL regular expressions in the "wikis" list in "farmconfig.py".]]></screen><itemizedlist><listitem override="none"><para>and you don't intend on using a serverfarm, remove the farmconfig.py and farmconfig.pyc files and try again. The error message shouldn't appear when you refresh the page. </para></listitem></itemizedlist></listitem><listitem><para>If you are using URLScan, you might have to add the following setting in the file <code>%SystemRoot%\system32\inetsrv\urlscan\urlscan.ini</code>:</para><screen><![CDATA[[options]
AllowHighBitCharacters=1]]></screen></listitem></itemizedlist></section><section><title>Next Steps</title><itemizedlist><listitem><para>Backing up MoinMoin is simple. Look at <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/Win32MoinEasyBackup#">HelpOnInstalling/Win32MoinEasyBackup</ulink> for guidance (despite the somewhat misleading title, the procedure would be the same for IIS). </para></listitem></itemizedlist></section><!--rule (<hr>) is not applicable to DocBook--><para> <anchor id="trouble-shooting"/> </para></section><section><title><ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/TroubleShooting">Trouble-shooting</ulink></title><para><emphasis role="strong">How to deal with common errors</emphasis> </para><section><title>First follow the instructions</title><para>Moin has provided instructions for common usage.  Try creating a wiki using the default values within the instructions. Your wiki would then be stored where ours is, and named <code>mywiki</code> ... but you can change that place, and this name, AFTER you have a working wiki. The default values have been chosen carefully to work for most people on most platforms, or at least be a good start. </para><itemizedlist><listitem><para>First follow the instructions </para></listitem><listitem><para>Do not change any configuration option unless you must. </para></listitem><listitem><para>Play with a working wiki before you try to customize it. </para></listitem></itemizedlist></section><section><title>Change one thing at a time</title><para>When your wiki is running, go and customize it to your needs, but remember to change only one option at a time. You probably don't fully understand how all options work, and if you go and break few things in the same step, you will have hard time to fix it.  </para></section><section><title>Check That Your Webserver Can Use Python</title><para>This is also in <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/HelpOnInstalling/BasicInstallation#">HelpOnInstalling/BasicInstallation</ulink>.  Use this script: </para><screen><![CDATA[echo Content-Type: text/plain
echo
echo "Your web server is running as:"
id
echo "CGI scripts work"
echo "Now we try to invoke Python interpreters and get their versions:"
python -V 2>&1
python2.3 -V 2>&1
python2.4 -V 2>&1
python2.5 -V 2>&1
echo "Finished."]]></screen><para>to see if you can get it to announce that cgi works. Then you will also know which versions of python are usable.  This is especially handy for users with no root access. </para></section><section><title>Duelling Pythons</title><para>The most common problem you might encounter is when you have an old Python version installed into &quot;<code>/usr</code>&quot;, and a newer Python distribution into &quot;<code>/usr/local</code>&quot;; this is typical for GNU/Linux distributions that still come bundled with an old Python version. </para><para>In that case, if you enter &quot;<code>python</code>&quot; on your prompt, you will usually get the more recent Python interpreter, because &quot;<code>/usr/local/bin</code>&quot; is in your <code>PATH</code>. The situation is different in your webserver environment, and thus you might have to change the bang path of &quot;<code>moin.cgi</code>&quot;, like this: </para><screen><![CDATA["""
    MoinMoin - CGI Driver Script
...
"""]]></screen><itemizedlist><listitem><para>When installing, make sure you install with the version of python you want to run moin with. <code>python setup.py install</code> will install with the first python in the path, which may be the version you expect or not! <code>/usr/local/bin/python2.4</code> will install in specific python. You will have to use the same path in the moin server script. </para></listitem></itemizedlist></section><section><title>Missing file permissions</title><para>If you are root, the installed files may be readable only by root, but they must also be readable by the web server before the wiki will work. This includes both the Python modules and the site itself. For the data directory, the wiki engine also needs <emphasis>write</emphasis> access.  To fix this, first find out where the Python module directory is; look in <code>install.log</code>, or run the command:  </para><screen><![CDATA[python -c "import sys; print '%s/lib/python%s/site-packages' % ( sys.prefix, sys.version[:3] )"]]></screen><para>For the example below, we'll assume that the Python module directory is <code>/usr/local/lib/python2.4/site-packages</code>. Make the files world-readable using the following commands: </para><screen><![CDATA[cd /usr/local
chmod -R a+rX lib/python2.4/site-packages/MoinMoin]]></screen></section><section><title>Set Your Variables Carefully</title><para>Be especially careful when you retype instead of cut and paste. Quoting errors in <code>wikiconfig.py</code> can cause things to fail.  The following items are also variable issues.  Also, some features only work if they are enabled by their option in either <code>wikiconfig.py</code> or <code>farmconfig.py</code>. </para><section><title>moin.cgi found, Moin doesn't run</title><para>If you have to add the moin code location into the system path, make sure to specify the place above MoinMoin itself, so that the word MoinMoin is recognized during the import request.   </para></section><section><title>CSS files do not work</title><para>A very common error is missing CSS styles. Your wiki looks bare and ugly, unlike this nice wiki. In most cases, you did break the configuration by not reading the instructions. </para><para>The fix is very easy: make sure your Apache Alias and <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/ScriptAlias#">ScriptAlias</ulink> are <emphasis role="strong">NOT</emphasis> the same. </para><para>This Apache setup will <emphasis role="strong">never work</emphasis>: </para><screen><![CDATA[Alias /wiki/ "/prefix/share/moin/htdocs/"
ScriptAlias /wiki/ "/var/www/wiki/moin.cgi"]]></screen><para>The Alias is used to serve static files: css, images, etc. <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/ScriptAlias#">ScriptAlias</ulink> is used to hide moin.cgi from the url. You must use different values! You can use anything you like for <ulink url="https://wiki.hcoop.net/MoinMoin/InstallDocs/ScriptAlias#">ScriptAlias</ulink>, or Alias, but Alias must match the <code>url_prefix_static</code> configuration option. </para><para>Here is an example that works (the default): </para><screen><![CDATA[# Apache config
Alias /moin_static170/ "/prefix/share/moin/htdocs/"]]></screen><screen><![CDATA[# Wiki config
    url_prefix_static = '/moin_static170']]></screen></section></section></section></article>