Wiki Installation and Configuration

After reading Time Management for System Administrators by Thomas A. Limoncelli I wanted to try wiki system (one of the productivity tools he highly recommends) within our office because keeping the internal information up-to-date is becoming pretty difficult. Currently not everyone within the organization is able to update the information which I think is creating a big overhead. I wanted to change this with wiki system, so that the information will always be up-to-date and easy to manage.

Our requirements for the wiki system

  1. Should be accessible only from our office LAN.
  2. No anonymous view/edit/create.
  3. No self registration.
  4. Registered users have full right to view/edit/create pages.

Choosing the software

Initially I thought I’d try TWiki recommended by Thomas but once I visited their site I felt little awkward because the site doesn’t display properly in firefox. So, I Googled for a while and landed at How to Start a Wiki which then led me to Top Ten Wiki Engines. The first on the top ten list was Moin Moin (I’m sure it is in the first place for a reason but for me the name didn’t click). So, I choose the second one Media Wiki. The same software used by Wikipedia.

Installation and Configuration

MediaWiki requires Apache, MySQL and PHP. It can be installed both in Linux/Unix and windows. My installation was done in CentOS 3.x. They have a very good, detailed Installation Guide. Following are the actual steps necessary for installation:

  1. Download MediaWiki
  2. Extract the tar in document root directory:
    tar -xvzf mediawiki-*.tar.gz
  3. Create MySQL database.
  4. Change the config folder ownership:
    chown apache
  5. Browse the site url and follow instructions.
  6. After the installation is complete move LocalSettings.php file from config to root directory and remove the config folder.

Configuration

Access Restriction to wiki

Add the following lines in LocalSettings.php after this line: require_once( "includes/DefaultSettings.php" ); Result of the configuration will be: users cannot create their own account and cannot read/edit documents without logging in to the system.

  • $wgGroupPermissions[‘*’ ][‘createaccount’] = false;
    $wgGroupPermissions[‘*’ ][‘edit’] = false;
    $wgWhitelistRead = array( "Special:Userlogin" );
    $wgGroupPermissions[‘*’ ][‘read’] = false;

To allow browsing only from particular ip address (e.g. office lan only) insert the following lines to .htaccess file:

  • <Limit GET POST>
    order deny,allow
    deny from all
    allow from "Office LAN IP"
    </Limit>

Rewrite Rules to have nice urls (Eliminating index.php from url). e.g.

http://mywiki.site.tld/wiki/Article_name

There are many ways to achieve this. I did it with .htaccess file:

  1. mediawiki was installed in the document root directory www.mysite.com/ (using the installer)
  2. set $wgArticlePath = "/wiki/$1"; in LocalSettings.php
  3. put a .htaccess file with the following content in the dir for www.mysite.com
  • # not actually needed but probably a good idea anyway
    php_flag register_globals off
    # first, enable the processing – Unless your ISP has it enabled
    # already. That might cause weird errors.
    RewriteEngine on
    # do the rewrite
    RewriteRule ^wiki/?(.*)$ /index.php?title=$1 [L,QSA]

4. Make sure Apache loads the rewrite modules

  • LoadModule rewrite_module modules/mod_rewrite.so

Default Global Timezone

To setup the the Hong Kong time insert the following lines to LocalSettings.php.

  • $wgLocaltimezone = "Asia/Hong_Kong";
    $oldtz = getenv("TZ");
    putenv("TZ=$wgLocaltimezone");
    $wgLocalTZoffset = date("Z") / 3600;
    putenv("TZ=$oldtz");

For other Timezones just change the first line e.g to set US, Los Angeles time the first line would be $wgLocaltimezone = "America/Los_Angeles";

File Uploads

File uploads are disabled by default so enable it in LocalSettings.php by:

  • $wgEnableUploads = true;

What now?

Read Help Editing for basic wikitext markup. It’s very easy. And create the user accounts by logging in as "sysop" (admin account).

I’ve to say that I’m very impressed with mediawiki. Specially the ease of installation and comprehensive documentation. I’m glad that I finally installed wiki system and I hope in the long run it will be a time saver for me as well as an effective information management tool within our organization.