<?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>HelpOnInstalling/ApacheWithModWSGI</title></articleinfo><section><title>Why use mod_wsgi?</title><para>See the <ulink url="http://modwsgi.org/">mod_wsgi</ulink> homepage. </para><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="http://ninux.org//moin_static197/ninuxtheme02/img/idea.png" width="16"/></imageobject><textobject><phrase>(!)</phrase></textobject></inlinemediaobject> Please note that its &quot;daemon mode&quot; should be the preferred way to use it (and this is the reason to prefer mod_wsgi over mod_python). </para></section><section><title>Basic configuring</title><orderedlist numeration="arabic"><listitem><para>Install mod_wsgi </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 configuration </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 MoinMoin 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_wsgi</title><para>Most people will just add a <code>mod_wsgi</code> package to their current operating system installation.  If you are building from source then you should consult the mod_wsgi documentation (it is rather easy if you have a development environment installed). </para><para>Make sure you have this line in your apache configuration or mod_wsgi will not work: </para><screen><![CDATA[LoadModule wsgi_module modules/mod_wsgi.so]]></screen><para>After this restart Apache and make sure that it starts successfully (also check the the error log). </para></section><section><title>Set up a wiki instance</title><para>This is done as shown in <ulink url="http://ninux.org/HelpOnInstalling/ApacheWithModWSGI/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_wsgi. This allows you be sure that any problems are in the mod_wsgi transition rather than the basic <ulink url="http://ninux.org/HelpOnInstalling/ApacheWithModWSGI/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: </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: </para><screen><![CDATA[data_dir = '/var/www/moin/mywiki/data/'
data_underlay_dir = '/var/www/moin/mywiki/underlay/']]></screen><para>Test that the wiki works after this change. </para></section><section><title>Changes to Apache configuration</title><para>After your wiki is running as cgi script, convert it to run with mod_wsgi.  </para><para>If you run your wiki as cgi as we recommended before, remove or comment the ScriptAlias directive: </para><screen><![CDATA[#ScriptAlias /mywiki "/var/www/moin/mywiki/moin.cgi"]]></screen><para>Add this to the same virtualhost definition: </para><screen><![CDATA[    # this is for icons, css, js (and must match url_prefix from wiki config):
    Alias       /moin_static160/ /usr/share/moin/htdocs/
]]><![CDATA[
    # this is the URL http://servername/moin/ you will use later to invoke moin:
    WSGIScriptAlias /mywiki /var/www/moin/mywiki/moin.wsgi
]]><![CDATA[
    # create some wsgi daemons - use someuser.somegroup same as your data_dir:
    WSGIDaemonProcess daemonname user=someuser group=somegroup processes=5 threads=10 maximum-requests=1000
    # umask=0007 does not work for mod_wsgi 1.0rc1, but will work later
]]><![CDATA[
    # use the daemons we defined above to process requests!
    WSGIProcessGroup daemonname]]></screen><para>Please also have a look into <code>moin.wsgi</code> - you maybe have to change some <code>sys.path.insert</code> instructions so Python can find the MoinMoin code and the wiki configuration. </para><para>Restart Apache - everything should now work correctly. </para></section></section><section><title>Configuring root wiki</title><para>See the same section on page <ulink url="http://ninux.org/HelpOnInstalling/ApacheWithModWSGI/HelpOnInstalling/ApacheWithModPython#">HelpOnInstalling/ApacheWithModPython</ulink>. </para></section></article>