Sunday, 27 April 2008

Backing and Restoring Mediawiki in Ubuntu

We are going to learn how to back up and restore our Mediawiki installed on a Ubuntu system.

To acomplish that we will execute some wiki maintenance commands.
These maintenance commands will be accesible after configuring AdminSettings.php file.

CONFIGURING AdminSettings.php FILE


AdminSettings.sample from the Mediawiki examples documentation will serve us as a model file to start.

We copy it into mediawiki configuration directory in /etc and assign the correct owner and permissions.
$sudo cp /usr/share/doc/mediawiki1.10/examples/AdminSettings.sample /etc/mediawiki1.10/AdminSettings.php
$sudo chown root:root /etc/mediawiki1.10/AdminSettings.php
$sudo chmod 600 /etc/mediawiki1.10/AdminSettings.php



Now we are going to edit AdminSettings.php file
$gksudo gedit /etc/mediawiki1.10/AdminSettings.php

Change these two variables using the parameters you used when creating the wiki database: e.g: wikiuser and its password.
$wgDBadminuser = 'DB user name'
$wgDBadminpassword = 'DB password'

Now that AdminSettings.php file is properly configured we are gonna back up and restore the wiki.


BACKING UP THE WIKI


dumpBackup.php command will back up our wiki:
$cd /var/lib/mediawiki1.10/maintenance
$sudo php dumpBackup.php --current > ~/foo_backup.xml

NOTE: --full option backups history of pages, not only last version as --current does.


RESTORING THE WIKI

Installing and Configuring Mediawiki on a Ubuntu Gutsy Desktop System

Mediawiki is the web based tool (wiki software) that Wikipedia uses to manage, store and serve its contents.

Mediawiki is written in PHP, and in this installation we will use MySQL as database management system (although it can be configured to use PostgreSQL)

Mediawiki is ditributed under the GNU GPL license.


INSTALLING MEDIAWIKI


First step is installing MySQL:
$sudo aptitude install mysql-admin mysql-server

It will ask you for MySQL root password. Then choose a secure password and type it.


Now we install Mediawiki itself:
$sudo aptitude install mediawiki

It will automatically check for apache and php dependencies.

Current mediawiki version is 1.10.


At installation I get this warning:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

There is some info in this thread at ubuntu forums.

To get rid of the error:
$gksudo gedit /etc/apache2/httpd.conf

httpd.conf file is usually empty, and then we add this line:
ServerName localhost

After saving the file we check if the error is gone executing this command:
$sudo apache2ctl restart


SETTING MEDIAWIKI URL ALIAS