MediaWiki

From Wikislax

Jump to: navigation, search

Contents

What is Mediawiki ?

Mediawiki is the powerful wiki software used by Wikipedia.

Installing Mediawiki

Download the software - a PHP application - so there is nothing to compile or make. Untar in any directory, for example /usr/local, and use a link from /var/www/htdocs/wiki.

# tar -C /usr/local -xvf mediawiki-x.y.z.tar.gz

Multiple instances

Instead of copying distribution files and directories under /var/www/htdocs for each wiki, it is possible to create directories of links pointing to the same original shared mediawiki installation, modifying only these files and directories differing across sites (obviously the databases will also have to differ) : /mw-config, /images, and LocalSettings.php.

# cd /var/www/htdocs
# mkdir wiki
# cd wiki
# mkdir mw-config
# mkdir images
# cp -R /usr/local/mediawiki-x.y.z/mw-config .
# cp -R /usr/local/mediawiki-x.y.z/images .
# ln -s /usr/local/mediawiki-x.y.z/* .
# cd ..
# chown -R apache:apache wiki

Configuring Mediawiki

Create an empty database wikidb and database user wikiuser on localhost. This can be done using phpMyAdmin. Then point your browser to the newly created wiki directory to run the installation script. Click the “Install MediaWiki” button, make sure it worked, then move file LocalSettings.php to the wiki directory. Use your browser again to visit the newly configured wiki directory.

# chown -R apache:apache LocalSettings.php

Mediawiki Security

When releasing a free-write-access MediaWiki site, you might find that low-attention pages start to get filled with spam messages. To avoid that, you can restrict write-access to adminitrators by adding the lines below to LocalSettings.php. The login token is encrypted, so that would be hopefully enough to keep spammers out.

$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['sysop']['edit'] = true;
$wgGroupPermissions['*']['createaccount'] = false;

Rendering Math

Mediawiki's extension:math affords rendering math. It requires compilation of texvc which requires installing ocaml, that you can download from http://caml.inria.fr. Install in the usual way then compile using the instructions in INSTALL :

# tar -C /usr/local -xvf ocaml-x.y.z.tar.gz
# cd /usr/local
# chown -R root:root ocaml-x.y.z
# cd ocaml-x.y.z
# ./configure
# make world
# make bootstrap
# make opt
# make opt.opt
# umask 022
# make install
# make clean

Get extension:math source code from git, run update.php twice (we have found that table wiki.math is created only during second run), then compile texvc, make sure that files created are owned by apache then link in /usr/bin :

# cd /var/www/htdocs/wiki/extensions
# git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Math.git
# cd ..
# ln -s /var/www/htdocs/wiki/LocalSettings.php /usr/local/mediawiki-x.y.z
# cd maintenance
# php update.php
# php update.php
# rm /usr/local/mediawiki-x.y.z/LocalSettings.php
# cd ../extensions/Math/math
# make
# chown apache:apache *
# ln -s /usr/local/mediawiki-x.y.z/extensions/Math/math/texvc /usr/bin

Also link latex, dvips, and dvipng in /usr/bin (/usr/local/bin doesn't work because of environment questions when ran under apache) :

# ln -s /usr/share/texmf/bin/latex /usr/bin
# ln -s /usr/share/texmf/bin/dvips /usr/bin
# ln -s /usr/share/texmf/bin/dvipng /usr/bin

Latex needs math and tmp directories :

# cd ../../../images
# mkdir math
# mkdir tmp
# chown apache:apache *

Last modify your LocalSettings.php file adding the lines below at the end of the file. Lines $wgShowDebug = true; $wgDebugComments = true; $wgEnableParserCache = false; $wgCachePages = false; will make troubleshooting easier. When testing, also use Firefox's « Tools » « Clear recent history... » « Cache » to reinitialize the cache before page reloads. Otherwise you can never be totally sure if your last change had no effect or was just not taken into account due to the cache.

#################################################################################
# math changes
#################################################################################

require_once("$IP/extensions/Math/Math.php");
$wgTexvc = '/usr/bin/texvc';

# $wgUseTeX = true;
# $wgShowDebug = true;
# $wgDebugComments = true;
# $wgEnableParserCache = false;
# $wgCachePages = false;

From this point, mathematical expressions such as <math>\sqrt{1-e^2}</math> will be correctly displayed in mediawiki. Not working ? su apache then try execuring commands such as texvc /home/wiki/tmp /home/wiki/math "y=x+2" to observe behaviour interactively.

Also check page http://www.mediawiki.org/wiki/Manual:Troubleshooting_math_display_errors.

Wiki Maintenance

Maintenance scripts are included in the maintenance subdirectory. To work, the maintenance scripts require a copy of the LocalSettings.php file in the parent directory. If the maintenance subdirectory is a link as described in the "Multiple instances" paragraph above, then the LocalSettings.php file must be copied or linked under the /usr/local/mediawiki-x.y.z first.

# cd /var/www/htdocs/wiki
# ln -s LocalSettings.php /usr/local/mediawiki-x.y.z
# cd maintenance
# php deleteOldRevisions.php --help
# rm /usr/local/mediawiki-x.y.z/LocalSettings.php

Here are a few useful scripts. Be sure to check /usr/local/mediawiki-x.y.z/maintenance directory and README file to find more maintenance scripts.

Script Usage
changePassword.php Reset the password of a specified user
deleteOldRevisions.php Erase old revisions of pages from the database
edit.php Edit a page to change its content
importImages.php Import images into the wiki
importTextFile.php Import the contents of a text file into a wiki page
moveBatch.php Move a batch of pages
nukePage.php Wipe a page and all revisions from the database
undelete.php Undelete all revisions of a page


PhpMyAdmin Main Page RoundCube
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox