MediaWiki

From Wikislax

Revision as of 17:04, 12 June 2012 by WikiSysop (Talk | contribs)
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 you 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

To have math rendered, you have to change the line and set $wgUseTeX = true; in LocalSettings.php. Also add lines $wgShowDebug = true; $wgDebugComments = true; $wgEnableParserCache = false; $wgCachePages = false; that will make troubleshooting easier. When testing, use « Tools » « Clear recent history... » « Cache » to reinitialize the cache before page reload. 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.

Texvc compilation uses ocaml, that you can download from http://caml.inria.fr. Install the file 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

Download extension texvc untar in directory /usr/local/mediawiki-x.y.z/extension, make sure that the new files created are owned by apache, then link in /usr/local/bin :

# tar -C /usr/local/mediawiki-x.y.e/extensions
# cd /usr/local/mediawiki-x.y.z/extension/Math/math
# make
# chown apache:apache *
# ln -s /usr/local/mediawiki-x.y.z/math/texvc /usr/bin

Also link latex and dvips in /usr/bin (/usr/local/bin doesn't work)

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

Latex needs a math directory :

# cd images
# mkdir math
# chown apache:apache math

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

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