An open source wiki engine which is available under the GNU General Public License.

It's used in Wikimedia projects (Wikipedia, Wiktionary, Wikisource, Wikibooks...)

See: http://www.mediawiki.org/

Debian package

The Debian package, which is also found in Ubuntu, does some odd things to MediaWiki to fit in with the odd things Debian does to Apache.

This page tries to list those changes, for the benefit of end users coming from using a tarball.

* pkg-mediawiki-devel list at Debian

Status

*mediawiki-distributors list

Specified versions will be maintained as long-term supported (LTS), with support from WMF and the distro packagers.

Debian changes to Apache

README.debian details much of what you need to know.

* httpd conf in /etc/apache2
* htdocs in /var/www (default)
* logs in /var/log/apache2 (default)

Sysadmins coming from using Apache tarballs should read [http://www.control-escape.com/web/configuring-apache2-debian.html this] page.

Debian changes to MediaWiki

*The package is maintained primarily with a view to being a component of [http://fusionforge.org/ FusionForge],<ref>http://lists.alioth.debian.org/pipermail/pkg-mediawiki-devel/2012-June/002017.html</ref> rather than as a standalone for people who just want to install a wiki.
*Apache rules are added in <tt>/etc/mediawiki/apache.conf</tt>
*The installer tells you to move the wiki configuration to <tt>/etc/mediawiki/LocalSettings.php</tt>
*The MediaWiki code is in <tt>/usr/share/mediawiki/</tt>, but
**<tt>LocalSettings.php</tt> and <tt>AdminSettings.php</tt> are symlinks to <tt>/etc/mediawiki/LocalSettings.php</tt> and <tt>/etc/mediawiki/AdminSettings.php</tt>
**<tt>config/</tt>, <tt>extensions/</tt>, and <tt>images/</tt> are symlinks to <tt>/var/lib/mediawiki/config/</tt>, etc.
*<tt>/var/lib/mediawiki/</tt> has <tt>config/</tt>, <tt>extensions/</tt>, and <tt>images/</tt>, along with symlinks back to <tt>/usr/share/mediawiki/includes/</tt>, <tt>/usr/share/mediawiki/index.php</tt>, etc.
*The Math extension is no longer shipped as core in upstream tarballs, and consequently not in the Debian package. It is in the <tt>mediawiki-extensions-math</tt>, and enabled with <tt>mwenext math</tt>.
*todo: mediawiki-extensions

Installation

Lenny

These instructions describe the installation of a monosite wiki on a LAMP server.

After the installation, the wiki will be avalaible on :

Install mediawiki package :

# apt-get install mediawiki php5-gd php5-xcache php-pear

Uncomment the alias line in /etc/mediawiki/apache.conf :

Alias /mediawiki /var/lib/mediawiki

Restart apache and go to http://www.myserver.org/mediawiki/config/index.php and fill in the form.

Copy settings in /etc/mediawiki/ and change file permissions :

# mv /var/lib/mediawiki/config/LocalSettings.php /etc/mediawiki/LocalSettings.php
# chgrp www-data /etc/mediawiki/LocalSettings.php
# chmod o= /etc/mediawiki/LocalSettings.php

You are ready to surf on your new wiki using this url:

sid

$ apt-get install mediawiki mediawiki-math

$ a2enmod rewrite

Install mysql, and setup this apache configuration:

<VirtualHost *>
    ServerName wiki.yourdomain.com
    ServerAdmin your@email

    RewriteEngine on
    RewriteRule (.*) /var/lib/mediawiki/$1

    <Directory /var/lib/mediawiki/>
        Options +FollowSymLinks
        AllowOverride All
        order allow,deny
        allow from all
    </Directory>

    # some directories must be protected
    <Directory /var/lib/mediawiki/config>
        Options -FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/lib/mediawiki/upload>
        Options -FollowSymLinks
        AllowOverride None
    </Directory>
</VirtualHost>

restart apache and go to http://wiki.yourdomain.com/config/index.php, fill in the form, copy ?LocalSettings to /etc/mediawiki/LocalSettings.php and that's it.

Configuration

changing the address to /wiki

The default address is:

http://wiki.domain.org/index.php/Main_Page

but this is nicer:

http://wiki.domain.org/wiki/Main_Page

To have that, change this in your apache configuration:

-    RewriteEngine on
-    RewriteRule (.*) /var/lib/mediawiki/$1
+    Alias /wiki /var/lib/mediawiki/index.php
+    Alias /index.php /var/lib/mediawiki/index.php
+    Alias /skins /var/lib/mediawiki/skins
+    Alias /images /var/lib/mediawiki/images
+    Alias / /var/lib/mediawiki/index.php

and add this to your /etc/mediawiki/LocalSettings.php:

$wgArticlePath       = "/wiki/$1";

Don't forget to clean the cache and cookies in your browser, otherwise it may look like it doesn't work for you, while it does.

Extensions

There is many extensions for Mediawiki. Somes are provided by packages (mediawiki-*) but you can install other extensions in /var/lib/mediawiki/extensions/

To activate an extension, create a php script in /etc/mediawiki-extensions/extensions-available/ and run the command mwenext.

To disable a script, use the mwdisext command.

source code highlighting

$ apt-get install mediawiki-extensions
$ mwenext SyntaxHighlight_GeSHi.php

See man mwenext for info how it works.

When you do changes like this one, don't forget that mediawiki uses cache, so if some page still shows the old code, you need to purge the cache, for example by loading the page with "?action=purge" added to the end of its URL.

Moving mediawiki to another server (=archiving+restoring)

Setup the wiki as described above, except creating the database. Copy /etc/mediawiki/LocalSettings.php from the old server to the new server.

Setup a tunnel

$ ssh -L 3306:localhost:3306 server

Test the connection:

$ mysql -h 127.0.0.1 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25383
Server version: 5.0.51-2 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> Bye

Create a database dump (read the "database_name" from /etc/mediawiki/LocalSettings.php)

$ mysqldump database_name -h 127.0.0.1 -u root -p > db.sql

Create the tunnel to the other computer:

$ ssh -L 3306:localhost:3306 server2

Create the database:

$ mysql -h 127.0.0.1 -u root -p
mysql> create database wikidb;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    -> ON wikidb.*
    -> TO 'wikiuser'@'localhost'
    -> IDENTIFIED BY 'some_password';
Query OK, 0 rows affected (0.01 sec)

mysql> Bye

Restore the database:

$ mysql wikidb -h 127.0.0.1 -u root -p < db.sql

Copy the images from /var/lib/mediawiki/images from the old server to the new server by hand.

When the database already exists and you just want to update it, still use the command above, it will do the right thing. Another variation of the above command is

$ gunzip < wikidb.sql.gz | mysql -h 127.0.0.1 -u root -ppassword wikidb

References

MySQL:

phpMyAdmin:

Credits

This page is under the GNU GPL2 license; parts of it were relicensed from a a text released under non-incompatible GFDL 1.2 and CC-BY-SA 3.0 licenses by its authors (mainly David Gerard).


CategoryPackaging CategoryPackageManagement CategorySoftware CategoryOfficeApplication