Using MoinMoin with apache + mod_python
mod_python 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 by your apache server!
mod_python versions before 3.1.3 have a bug in apache.resolve_object This bug is fixed in version 3.1.3 an will perhaps fixed in later 2.X releases for apache 1.3.
Deploying MoinMoin with mod_python
Follow the basic apache installation for your operating system as described in other parts of the MoinMoin installation documentation. Don't copy moin.cgi, cause you won't need it. Be sure that the apache process can access the wiki data files (check User and Group in your apache.conf).
Copy the sample moin_modpy.htaccess as .htaccess to the path below which your wiki instance should be found:
cd /usr/local/share/moin cp wiki/cgi-bin/moin_modpy.htaccess /path/to/your/docroot/.htaccess
Check the .htaccess that the PythonPath matches your installation. It should contain the path where the moin_modpy.py wrapper is installed (Note: the wrapper does not have to be within your DOCROOT). You can also change the name of your instance (<Files wikiname>).
In some cases you need to restart apache after changes to py files used by mod_python. Please refer to the mod_python documentation.
reading of .htaccess
In SuSE Linux 9.0 reading of .htaccess is switched off by default in "/etc/apache2/http.conf" with
* forbid access to the entire filesystem by default <Directory /> Options None AllowOverride None Qrder deny, allow Deny from all </Directory>
To allow Apache processing your .htaccess file (in your document root) you have to modify "/etc/apache2/http.conf" (for SuSE it is actually recommended to create a new "http.conf.local" and include it in "/etc/sysconfig/apache2").
<Directory "/src/www/htdocs" # this is the document root in Suse AllowOverride All </Directory>
Fixing the mod_python bug
If you did use the wrapper setup from the previous section, you don't need to do this.
mod_python has a small resolver bug in versions before 3.1.3. The method resolve_object in mod_python/apache.py checks the wrong object, and so the lookup for RequestModPy.run fails. You have two possibilities to live with it: either use the wrapper script moin_modpy.py or fix the bug.
To fix it you need to change the method resolve_object (around line 551 for mod_python 3.1.2b) from
if silent and not hasattr(module, obj_str): return None
if silent and not hasattr(obj, obj_str): return None
This bug is currently in all versions of mod_python before 3.1.3. It might be fixed in a next 2.X release for apache 1.3, too.
Deploying with a fixed mod_python
This section only works with a fixed mod_python (see previous section)!
Follow the deployment documentation above. Use the special commented out section of moin_modpy.htaccess instead of the default wrapper using part.
Check the PythonPath in the .htaccess that it matches your installation. It should contain the python lib path where the MoinMoin package is stored (not needed if MoinMoin is installed system wide) and the path to your wikiconfig.py.
The wrapper script moin_modpy.py is not needed, cause the !RequestModPy class is used directly by mod_python.
Installing to base root with ModPython
This stuff needs a security review/rewrite. Having data/ under document root or a directory configured to be available by the web server is a bad idea.
None of the above instructions work if you want to make MoinMoin work at the base url and use ModPython (i.e. http://www.myserver.com/ and not http://www.myserver.com/wiki ). Here is what worked for me for setting up MoinMoin for use with multiple virtual servers (these are instructions for modpython 3.1.3 or later):
Remember to replace "mywiki" in all these instructions with whatever name you chose.
I keep the folders for the various wikis as subdirectories of /usr/share/moin. Similar to the regular install instructions, do this after running python setup.py install for moinmoin:
cd /usr/share/moin mkdir mywiki cp -r data mywiki cp config/wikiconfig.py mywiki (this is the only file you need) chown -R www-data:www-data mywiki (use the user and group of apache)
Edit your apache configuration file to allow the moin parent folder to override !FileInfo at least:
<Directory "/usr/share/moin"> Options Indexes Includes FollowSymLinks MultiViews AllowOverride All #you need to allow FileInfo at least Order allow,deny Allow from all </Directory>
For your server or virtual host, you need to set at least the two Aliases:
<VirtualHost your.ip.address> ServerName your.server.name DocumentRoot /usr/share/moin/mywiki #not really necessary ServerAdmin firstname.lastname@example.org #This next line allows shared moinmoin images to load Alias /wiki/ "/usr/share/moin/htdocs/" #This is the line that passes a name to your python handler, # the trailing slash is necessary Alias / "/usr/share/moin/mywiki/" </VirtualHost>
sitename = 'My Wiki' interwikiname = 'MyWiki' data_dir = '/usr/share/moin/mywiki/data/' #this needs to be a FULL path
And most importantly, you need to add an .htaccess file under /usr/share/moin/wiki1/ (or else add these lines to your main httpd.conf file:
# PythonDebug On <Files mywiki> SetHandler python-program PythonPath "['/usr/share/moin/mywiki/']+sys.path" PythonHandler MoinMoin.request::RequestModPy.run </Files>