Puppet ? No wait, mediawiki under Fedora 9


I was going to write about getting Puppet to work under Fedora 9, but I found out it's really nont difficult. As an excercise for myself I decided to try and make a puppet recipe for mediawiki.
This is turning out harder than expected. Not because puppet is so hard (it's really not), but because the mediawiki RPM package in Fedora 9 is terribly bad.

As a comparison, let me tell you how to get mediawiki working on a freshly installed Debian. OK, ready ? Here it comes:


apt-get install mediawiki

And it's done !

Right, now let's see what you need to do to get this working under Fedora 9.

yum install mediawiki

Everything starts off nice and fine

yum install mysql-server

Unlike under Debian, Fedora 9 doesn't assume that you want to have a local MySQL server running. By not installing it, it gives you the choice. Not a bad thing.


chkconfig httpd on
service httpd start
chkconfig mysqld on
service mysqld start

Things are already getting weird. Why would I install mediawiki and then not want to run httpd by default ?


cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig
cat /etc/httpd/conf/httpd.conf.orig |sed 's:DocumentRoot \"/var.*:DocumentRoot \"/var/www\":' > /etc/httpd/conf/httpd.conf
service httpd restart

By default the DocumentRoot is set to /var/www/html, while mediawiki is installed under /var/www/wiki.


system-config-firewall-tui -p 80:tcp

Open up port 80 in the firewall, again this should have happened when I installed apache


cd /tmp
mkdir config
cp /var/www/wiki/config/index.php config/index.php.orig
cat config/index.php.orig |sed 's:\$DIR=.*:\$DIR="/tmp";:' > config/index.php


(cat <<EOF;
<?
\$_SERVER = array();
\$_POST = array();

\$_SERVER["SCRIPT_NAME"] = "/wiki/config/index.php";
\$_SERVER["PHP_SELF"] = "/wiki/config/index.php";

\$_SERVER["REQUEST_METHOD"] = "POST";

\$_POST["Sitename"] = "My Little Wiki";
\$_POST["SysopPass"] = "xxx";
\$_POST["SysopPass2"] = "xxx";
\$_POST["DBtype"] = "mysql";
\$_POST["DBpassword"] = "xxx";
\$_POST["DBpassword2"] = "xxx";
\$_POST["useroot"] = "on";
\$_POST["RootPW"] = "";
\$_POST["DBprefix"] = "";

include "config/index.php";
?>
EOF
) > genconfig.php

php genconfig.php
cp config/LocalSettings.php /var/www/wiki/
rm -rf /tmp/genconfig.php /tmp/config

What on earth is all this ? Well this code configures mediawiki with a default config. Instead of supplying a default config, Fedora lets you surf to your wiki, fill in some variables to generate a configfile, which you then have to copy to the correct place.

In the script I just pasted, this is all done automagically. I fake the execution environment of the config/index.php script and execute it from commandline. It will create the necessary database and tables and generate a LocalSettings.php, which is then copied to the correct place.

ln -s /usr/share/mediawiki/skins/ /var/www/wiki/

After all this fiddling, the installed mediawiki still looks like crap. This is because the mediawiki apparently forgot where it placed the directory with all the skins. A symlink should fix that.

chmod a= /var/www/wiki/config

No need for this directory to be publicly avaiable.

Some of you have commented that I should read the INSTALL file as specified on this wiki.
Actually, I shouldn't have to because that's what packages are for. But just so you know, I did look there (/usr/share/mediawiki/INSTALL) (By the way, doesn't Fedora have some kind of policy where documentation should go ? What is /usr/share/doc for ?) and it doesn't mention anything about where to surf to (http://somewhere/wiki/) or whether or not to fix the skins directory.