MediaWiki

From shankerbalan.net
Jump to: navigation, search

Contents

Overview

[buffy] ~> cat /usr/ports/www/mediawiki/pkg-descr

MediaWiki is the collaborative editing software that runs Wikipedia, the free encyclopedia, and other projects. It's designed to handle a large number of users and pages without imposing too rigid a structure or workflow.

WWW: http://www.mediawiki.org/

Installation

Per http://www.mediawiki.org/wiki/Download_from_SVN

$ cd $HOME
$ mkdir svn; cd svn
$ svn checkout http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_12/phase3
$ mv phase3 mediawiki-1.12
$ ln -sf ~/svn/mediawiki-1.12 ~/public_html/wiki
$ ln -sf ~/public_html/wiki ~/public_html/w
$ ls -l ~/public_html/w
lrwxrwxrwx  1 shanu users 30 Feb 11 23:22 /home/shanu/public_html/w -> /home/shanu/svn/mediawiki-1.12/
$ ls -l ~/public_html/wiki
lrwxrwxrwx  1 shanu users 1 Dec 29 03:32 /home/shanu/public_html/wiki -> w

Setup

LocalSettings.php

The below configurations allows for the following access policy:

  1. Write access for logged in users
  2. Read access for everyone else
  3. Disable creation of new accounts

See http://www.mediawiki.org/wiki/Help:Configuration_settings

$ vi ~/public_html/wiki/LocalSettings.php
$IP = "/home/shanu/public_html/wiki";
$wgSitename         = "Shankerbalan.net";
$wgScriptPath       = "/wiki";
$wgEmergencyContact = "xxx@domain.com"
$wgPasswordSender   = "xxx@domain.com"
$wgDBserver         = "localhost";
$wgDBname           = "xxx";
$wgDBuser           = "xxx";
$wgDBpassword       = "xxx";
# ACLs
$wgGroupPermissions['*'    ]['createaccount']   = false;
$wgGroupPermissions['*'    ]['edit']            = false;

Logo

Dump a logo into your upload directory. I do this to keep my local changes away from the CVS tree. Due to lack of creativity, I am using the project logo itself.

$ vi LocalSettings.php
# # $wgLogo             = "$wgStylePath/common/images/wiki.png"; # comment out

$ find . -iname wiki.png  
./upload/wiki.png
./skins/common/images/wiki.png
./skins/monobook/wiki.png
$ mkdir upload
$ cp ./skins/monobook/wiki.png upload/
~public_html/wiki$ ls -l upload/wiki.png 
-rw-r--r--  1 shanu users 23064 2006-03-26 21:13 upload/wiki.png

.htaccess

# Comment after testing
Order Deny,Allow
Deny from All
Allow from .domain.com

robots.txt

Disallow: /w/
Disallow: /wiki/Special:Search
Disallow: /wiki/Special:Random

The above tell websites to turn off indexing on /w/ (and other special pages) which need not be indexed. The public facing wiki is at /wiki/ and not /w/.

Updating from SVN

Subscribe to the MediaWiki announce list at http://www.mediawiki.org/wiki/Communication. When an update is announced, follow the instructions as per http://www.mediawiki.org/wiki/Download_from_CVS#Upgrading_and_downgrading to perform the update.

$ cd ~/svn/mediawiki-1.12
$ svn up

Simple as that!

Pretty URLs

This has been a bitch for me. This is what I had to do to get http://shankerbalan.net/wiki/Blah looking URLs to work. The default is an ugly http://shankerbalan.net/wiki/index.php?topic=Blah. As I understand it (Apache mod_rewrite.c is too tricky for me), this is how its supposed to work.

  1. Mediawiki is installed in public_html/mediawiki/
  2. Symlink w and wiki is created to public_html/mediawiki/
  3. mediawiki/LocalSettings.php is updated as noted below
  4. public_html/.htaccess is updated as below
  • LocalSettings.php
$wgServer           = 'http://shankerbalan.net';
$wgServerName       = 'shankerbalan.net';
$wgSitename         = "shankerbalan.net";

$wgScriptPath       = "/w/";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";
$wgArticlePath      = "/wiki/$1";
  • .htaccess
# Rewrite http://shankerbalan.net/wiki/ to http://shankerbalan.net/w/Main_Page
RewriteRule ^wiki/$ /w/index.php?title=Main_Page [L,QSA]
# For other wiki URLs which have topic in them, normalize them
RewriteRule ^wiki/(.+)$ /w/index.php?title=$1 [L,QSA]

While playing around with the settings, it helps to pass ?action=purge so that the cached wiki links as mentioned in $wgArticlePath are purged. It was the number one problem for me while trying to figure out why the links were pointing to other locations. Also, the below Wiki URL suggests not to put mediawiki in the root document dir. I tried doing just that while redoing my website and it turned out to be a PITA. Having a wiki.shankerbalan.net instead of wiki.shankerbalan.net/wiki/ is also not recomended. YMMV!

See http://www.mediawiki.org/wiki/Manual:Short_URL

Upgrading From 1.4 to 1.12

Recently (July 2008), I noticed that my hosting provider has upgrader to PHP5 on Debian 4.0. An inplace upgrade was performed from 1.4 to 1.12 as per instruction in the svn/mediawiki-1.12/UPGRADE. Backed up the DB and exported XML as per http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki

$ cd ~/svn/
$ svn checkout http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_12/phase3
$ mv phase3 mediawiki-1.12
$ rm ~/public_html/w ; ln -sf ~/svn/mediawiki-1.12 ~/public_html/w
$ cp ~/svn/mediawiki-1.4/LocalSettings.php ~/public_html/w
$ cp ~/pubic_html/w/AdminSettings.sample ~/public_html/w/AdminSettings.php # fixup settings
$ chmod 600 ~/public_html/w/AdminSettings.php
$ cd ~/public_html/w/maintenance
$ php5 update.php
Personal tools