MediaWiki on SourceForge - The HOWTO

2006-03-03 10:13:20 GMT

This is my third and last post regarding the installation of MediaWiki on SourceForge.

In my first post, I concluded that it's not possible to install MediaWiki on SourceForge. In my second post, I acknowledged that it's doable and in this post of mine, in my third post on the subject, I'm gonna actually describe how to do it in a way that will make you understand what are you doing and why.

Just to let you know, what you're reading now is probably the most complete and clear HOWTO ever written on the subject. It's not that there aren't any resources out there, but they're not very usable or clear in my experience.
As an additional note, it wasn't fun to compile all this information into a quality document like this, but I was so pissed off by this issue and I wasted so much time with it, that I really don't wanna anyone out there to suck days with this process like I did. So if you're eager to install MediaWiki into your project web space on SourceForge, this guide will worth you pure gold. I should probably charge you, but I'm such a nice person…

Throughout this HOWTO, i'll mark text regions with bold formatting that are supposed to be replaced by your installation settings.

Here are the steps to make the thing happen:

  1. Deploy MediaWiki source on SourceForge:
    1. Download MediaWiki to your local machine.
    2. scp the tarball to your project web space, since outbound connections are forbidden from the SourceForge shell:
      $ scp mediawiki-version.tar.gz username@shell.sf.net:/home/groups/p/pr/projectname/htdocs
    3. Extract the tarball on SourceForge:
      $ ssh username@shell.sf.net
      $ cd /home/groups/p/pr/projectname/htdocs
      $ tar xzvf mediawiki-version.tar.gz
    4. Symlink the wiki directory, so we'll have less burden when upgrading to a more recent version of MediaWiki:
      $ ln -s mediawiki-version wiki
  2. Set up persistent directories. Since project directories on SourceForge are not writable by Apache, we need to create writable directories for storing volatile data and modify some configuration details accordingly:
    1. Create a persistent directory for your project in /tmp/persistent/tmpname. tmpname should be the same as your projectname. In case /tmp/persistent/projectname is already created by someone else, you need to choose another name.
      $ mkdir /tmp/persistent/tmpname
    2. Create writable directories for initial configuration, session management and image data:
      $ cd /tmp/persistent/tmpname
      $ mkdir config sessions images
      $ chmod a+w *
    3. Symlink the config and images MediaWiki directories to your persistent directory:
      $ cd /home/groups/p/pr/projectname/htdocs/wiki
      $ cp config/index.php /tmp/presistent/tmpname/config
      $ rm -f config/index.php
      $ rmdir config
      $ ln -s /tmp/persistent/tmpname/config
      $ rm -f images/.cvsignore images/README
      $ rmdir images
      $ ln -s /tmp/persistent/tmpname/images
  3. Prepare the source for installation. /home/groups/p/pr/projectname/htdocs/wiki/config/index.php needs to be hacked in order to work correctly with the persistent directory setup:
    1. Point to the correct wiki root directory by replacing line 117:
      $IP = dirname( dirname( __FILE__ ) );
      with:
      $IP = "/home/groups/p/pr/projectname/htdocs/wiki";
      and by replacing line 1125:
      \$IP = \"{$slconf['IP']}\"
      with:
      \$IP = \"/home/groups/p/pr/projectname/htdocs/wiki\"
    2. Point to the correct languages directory by replacing line 1296:
      global $wgLanguageNames;
      with:
      global $wgLanguageNames, $IP;
      and by replacing line 1306:
      $d = opendir( "../languages" );
      with:
      $d = opendir( "$IP/languages" );
    3. Point to the correct SQL database definition files by replacing all the "dbsource( "../" strings with "dbsource( "$IP/" strings. (Watch for the space after the parantheses.)
  4. Install MediaWiki. Point your browser to http://projectname.sf.net/wiki/config and install MediaWiki through its web interface:
    1. Select Turck MMCache for shared memory caching.
    2. Use your MySQL admin account as the DB username.
    3. On the end of the page there should be an "Installation successful!" message. If it's not there, the installation may have interrupted due to server suckiness which happended to me several times. If that's the case, you should rerun this script. You may also want to drop your wiki database prior rerunning the install script if things don't work out.
    4. Move the generated LocalSettings.php to the wiki root directory:
      $ mv /tmp/persistent/tmpdir/LocalSettings.php /home/groups/p/pr/projectname/htdocs/wiki
    5. Remove old config, since there's no use of it and it also imposes a security risk:
      $ rm -f /tmp/persistent/tmpname/config/index.php
      $ rmdir /tmp/persistent/tmpname/config
      $ rm -f /home/groups/p/pr/projectname/htdocs/wiki/config
    6. Correct the default session save path by including into /home/groups/p/pr/projectname/htdocs/wiki/LocalSettings.php at the end of the PHP section:
      session_save_path("/tmp/persistent/tmpdir");
  5. Fine-tune MediaWiki for the environment. You have a workable MediaWiki installation at this point, but there are still several steps to be made in the current environment:
    1. Restrict editing permissions by including into LocalSettings.php:
      $wgGroupPermissions['*']['edit'] = false;
      $wgGroupPermissions['user']['edit'] = false;
    2. Display SourceForge logo. SourceForge requires every projects to display their logo on every project web page for statistical and PR purposes. There are plenty of docs on this topic.

Thanks

I'd like to thank Diego Torres Milano, developer of the JGlade project for writing the mediawiki-sf installation script which I learned a lot from.


Comment written by zzorn at 2007-06-14 08:12:50 GMT:

Thanks for the instructions!

I noted that Noel had some corrections to the guidelines on his blog, posting the link here for the benefit of others.


Comment written by claudius at 2007-10-13 16:48:04 GMT:

Thanks all of you for publishing all these. It would have been such a burden without you guys.


Comment written by Jeremy Harmon at 2007-11-08 04:40:25 GMT:

For some reason the creation of tables failed when installing it using 1.6.10. I manually added the tables.sql schema (in the maintenance folder), and re-ran the install, works fine now.