Tweaks for getting MoinMoin to work on Hurricane Electric

Problem: You want to install a wiki but you don't have root access to Apache or the required version of Python. However, you can use .htaccess to configure CGI or mod_rewrite.

Solution:

  1. Install Python locally (use prefix=/home/user/yourPythonPlace)
  2. Install MoinMoin (use prefix=/home/user/yourPythonPlace)

  3. Depending on what/how you call your wiki and how you want the URLs to look, see below:

First off, it's natural to make a directory within your public_html dir called: wiki, and then want to serve your wiki from there. The default behavior of moinmoin appears to reference the moin.cgi script within URL calls to the wiki. So if you have wiki page about MyFoo, the url would look something like:

http://www.yoursite.com/wiki/moin.cgi/MyFoo

Whereas, the URL most people would like to use is:

http://www.yoursite.com/wiki/MyFoo

I tried for several days to figure out how to use mod_rewrite to rewrite the URLs so that users would not see the reference to moin.cgi. Since I can do CGI in the wiki directory, I had left the moin.cgi script in the wiki directory, instead of placing it in cgi-bin. Although I could re-write URLs, for some reason the moin.cgi script always crashed if it was in the wiki directory from which the URLs were being re-written. However, moving it somewhere else solved the problem. In the end, the only solution I could find was to put moin.cgi somewhere other than the wiki directory, and re-write URLs to reference it in that other location. The following .htaccess directives to mod_rewrite seem to work:

Configuring mod_rewrite for nice URLs

Assuming your wiki is in the directory /wiki, you would make a .htaccess file with the following directives and place it in that directory.

RewriteEngine on
# skip refereces to real directories with stuff in them
RewriteRule ^/?classic/ - [last]
RewriteRule ^/?common/ - [last]
RewriteRule ^/?modern/ - [last]
RewriteRule ^/?applets/ - [last]
RewriteRule ^/?rightsidebar/ - [last]
# By default, everything else is an argument to moin.cgi
# so match WikiWords and arguments and hand them to moin.cgi
RewriteRule ^/?(.*)$ ../YourPathTo/moin.cgi/$1 [type=application/x-httpd-cgi] 

The dash in the RewriteRule means: do nothing. The [last] directive means don't do anymore evaluations if this one matches. So each of the first 5 rules says, "if the URL matches something in this directory, do nothing and exit."

The confusing thing about this scenario is that the style sheets and other stuff for the wiki are in the /wiki directory, so why can't moin.cgi be there too? However, since it's not there, and anything in the URL after the /wiki part needs to be handed to moin.cgi, you have to distinguish between the static stuff that IS there and the imaginary WikiWords that moin.cgi will build pages about. Thus the first 5 re-write rules ignore URLs that point to the static stuff that is in the wiki directory, while the last RewriteRule hands everythign else to moin.cgi (whereever it happens to be). If you re-write the URLs you also have to configure the moin.cgi script as decsribed in the MoinMoin docs by changing request = RequestCGI() to:

request = RequestCGI(properties = {'script_name': '/wiki'})

This change affects how the moin.cgi script is referred to in URLs when pages are constructed.

MoinMoinInstall (last edited 2009-03-28 23:12:12 by ChrisSeidel)