How to Setup MediaWiki for Enterprise?

[MediaWiki is an open source wiki which runs Wikipedia – anybody can download it and use it]

We managed to setup MediaWiki for our Enterprise 2.0 initiative. We had to take care of some basic security needs. Our platform was: Windows Server 2003, Apache, and MySQL.

Let me document what we did. (I need to thank Radha who has done most of the actual work and also supplied me with the details to write this post)

Installation for the basic software

  1. Download MediaWiki, Apache, PHP and MySQL from respective sites and install them on the designated machine
  2. While installing PHP (do it after installing Apache), ensure you enable support for MySQL, MS-SQL and any other database support you will need in the future
  3. Any changes that need to be done in Apache has to be in the /conf/httpd.conf file – These may include the port that Apache is listening on, Document root (if your MediaWiki is not installed under Apache/htdocs), etc.
  4. Copy MediaWiki into Apache’s htdocs
  5. Point your browser to MediaWiki’s CONFIG directory/index.php and follow instructions
  6. The process will setup MediaWiki and you will be able to access it from the URL you installed it in e.g., http://localhost/wiki/ or http://n.n.n.n/wikiname or
  7. The installation will create a file called localsetttings.php in the CONFIG folder. Move this file to the root MediaWiki folder
  8. Delete the CONFIG directory
  9. Localsettings.php is the main configuration settings file for MediaWiki. The settings for the wiki can be changed in this
  10. The mediawiki/includes folder contains a file called Defaultsettings.php.

Changes and additions to MediaWiki configuration settings can be copied from Defaultsettings.php onto Localsettings.php but at any cost Defaultsettings.php must never be edited.

See also: MediaWiki – Newcomers guide to installing on Windows, MediaWiki – Installing MediaWiki, – MediaWiki Installation, MediaWiki – Manual:Configuration settings

Put your own logo

Add the following line to Localsettings.php and place your logo in … directory

$wgLogo = “{$wgScriptPath}/file name of your logo“;

See also: MediaWiki – Manual:$wgLogo

Implement access control – no access to the wiki without logging in

Add the following lines to Localsettings.php

$wgGroupPermissions[‘*’][‘read’] = false;
$wgGroupPermissions[‘*’][‘edit’] = false;
$wgWhitelistRead = array (“Special:Userlogin”);

See also: MediaWiki – Manual:$wgGroupPermissions, MediaWiki – Manual:$wgWhitelistRead

To restrict user creation by administrator only

Add the following line to Localsettings.php

$wgGroupPermissions[‘*’][‘createaccount’] = false;

See also: MediaWiki – Manual:$wgGroupPermissions

Enabling image and attachment upload

Add the following line to Localsettings.php. You can include different types of file extensions that you would like to enable upload for.

$wgFileExtensions = array(‘png’, ‘gif’, ‘jpg’, ‘jpeg’, ‘doc’, ‘xls’, ‘mpp’, ‘pdf’, ‘zip’, ‘ppt’);

See also: MediaWiki – Manual:$wgFileExtensions

Alternately, if you want to allow all file extensions to be allowed, add the following line.

$wgCheckFileExtensions = false;

See also: MediaWiki – Manual:$wgCheckFileExtensions

To implement suggest on the search box (auto-complete of a search item)

Add the following line to Localsettings.php.

$wgEnableMWSuggest = true;

See also: MediaWiki – Manual:$wgEnableMWSuggest

Implement parser function extension

[Note: You will need this extension if you want to include the nice looking Infobox that appears on the right side of many of the Wikipedia pages]

Download ParserFunctions extensions and extract it to your extensions directory.

See also: MediaWiki – Extension:ParserFunctions

Add the following line to Localsettings.php.

$wgExpensiveParserFunctionLimit = 100;
require_once( “$IP/extensions/ParserFunctions.php” );

See also: MediaWiki – Manual:Extensions, MediaWiki – Help:Extension:ParserFunctions

To take all non logged in user directly to login page

[Warning: You need to make code change to implement this feature]

Modify the public function loginToUse()in OutputPage.php. You will find the file in the include subdirectory.

$skin = $wgUser->getSkin();

# Begin – Code to redirect to the login page is user has not logged in
$this->mRedirect = SpecialPage::getTitleFor(‘UserLogin’) ->getFullURL() . ‘?returnto=’ . $wgTitle->getPrefixedUrl();
# End – Code to redirect to the login page is user has not logged in

$this->setPageTitle( wfMsg( ‘loginreqtitle’ ) );
$this->setHtmlTitle( wfMsg( ‘errorpagetitle’ ) );
$this->setRobotPolicy( ‘noindex,nofollow’ );
$this->setArticleFlag( false );

Add additional icons in edit toolbar

[Warning: You need to make code change to implement this feature]

Modify the static function getEditToolbar()in EditPage.php. You will find the file in the include subdirectory. Following lines need to be added to the $toolarray initialization.

‘image’ => $wgLang->getImageFile(‘button-table’),
‘id’ => ‘mw-editbutton-table’,
‘open’ => “{|”,
‘close’ => “|}”,
‘sample’ => ‘class=wikitable border=1 cellpadding=2
|+ table name
! header 1
! header 2
! header 3
! row 1, cell 1
! row 1, cell 2
! row 1, cell 3
! row 2, cell 1
! row 2, cell 2
! row 2, cell 3
‘tip’ => wfMsg(‘table_tip’),
‘key’ => ‘A’

See also: MediaWiki – Manual:Custom edit buttons

We have just started exploring the engine. Lot more can be done with it!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: