Mediawiki Upgrade

For several years now I’ve been running a local instance of Mediawiki, and in that time I’ve only upgraded it once. And that’s a problem. Because now I’m scared to touch it.

Sure, I perform backups regularly. But I’m scared I’ll lose all those years of content if something goes wrong. And an upgrade would require hours I don’t have. Or so I thought.

With a litte free time and an acceptance that things may break, I jumped in. And since I’m disturbing things, I may as well upgrade Apache HTTP Server and PHP at the same time. My main reference in this quest was the Mediawiki upgrade guide.

Environment

Since this is just a local dev environment, it is pretty basic:

  • Windows 10 64-bit
  • MySQL Server 5.6
  • Apache 2.2.25 (x86)
  • PHP 5.4.33 (x86)
  • Mediawiki

The existing Mediawiki installation is deployed to \htdocs\mediawiki\. To minimise risk, and to mitigate any interruptions, I opted for a new istallation alongside the existing one.

Step 1. Preparation

Hopefully this stuff is already performed on a regular basis, especially if you value your wiki contents.

Backup SQL

First we can check which databases we have. Launch a command prompt and type the following, replacing [user] and [pass] as appropriate for your installation.

cd C:\MySQL5.5\bin

mysql -h localhost -u [user] –p[pass]

mysql> show databases;

mysql> exit

Now backup the Mediawiki database, replacing [dbname] and [backup_file_name] as appropriate.

mysqldump -u [user] -p[pass] [dbname] > [backup_file_name].sql

Also see the Mediawiki Manual Backing up a wiki.

XML Export

Mediawiki provides a utility to export the wiki contents as XML using dumpBackup. According to the documentation, “XML dumps contain the content of the wiki (wiki pages with all their revisions), without the site-related data (they do not contain user accounts, image metadata, logs, etc).” Sounds good to me.

Note that this requires you to have php in your PATH variable.

cd \htdocs\mediawiki\maintenance

php dumpBackup.php --full > dumpfile.xml

If things go bad later on we can roll back using importDump:

php importDump.php < dumpfile.xml

Backup directory

Lastly we want to backup the entire Mediawiki installation directory at \htdocs\mediawiki

Step 2. Install Apache & PHP

At this stage I found some help from Moodle documentation. First, download Apache and extract it into a new directory. Then launch a command prompt and type:

cd \Apache24\bin
httpd -k install
httpd -k start

Then I used DiffMerge to compare httpd.conf with the original, and addressed any differences.

The same Moodle documentation also steps through installing PHP. The Mediawiki Compatibility page notes that MediaWiki is not yet fully compatible with PHP 7.1 (at the time of writing). I also noted that PHP 7 does not seem to have support for MySQL. For these reasons I stuck with the latest stable release of PHP 5.

Again, I used DiffMerge to compare php.ini with the original, and address any differences.

Step 3. Upgrade Mediawiki

  1. Download the latest stable release of Mediawiki and extract into a new directory within Apache’s /htdocs
  2. Copy and replace the existing images directory and LocalSettings.php from the old installation
  3. In a browser navigate to http://[yourwiki]/mw-config/ and follow the prompts to complete the upgrade

If you want a fresh LocalSettings.php, skip copying it and run the upgrade wizard to generate a fresh one. Then use DiffMerge or similar to compare the differences.

Step 4. Apply a skin

Edit LocalSettings.php and add the following:

$wgDefaultSkin = 'MonoBook';
wfLoadSkin( 'MonoBook' );

I haven’t experimented with additional skins, but the Mediawiki Manual Skins is a great reference. For many, a familiar place to start is the skins based on Bootstrap.