Manual:Running MediaWiki on Debian or Ubuntu

=Introduction= This guide is to help other users install WikiMedia on an Ubuntu server installation via a VMware virtual machine

Some PC knowledge is requried, ie: installing applications and Operating Systems.

If you are not going to use VMware virtual machines, then please just ignore that section.

=Step-By-Step=

Gather the required software
Download the latest server version of Ubuntu Linux from http://www.ubuntu.com in ISO format Download the latest version of VMware Server from http://www.vmware.com

VMware Installation
Install VMware server onto your target PC Configure a new virtual machine, allow about 30Gb of drive space, and a minimum of 256Mb of RAM. It is not required to allocate the entire drive space at this time

Install Ubuntu
Using the previously downloaded ISO image for Ubuntu,
 * If you are using a virtual machine, apply this as the CD-ROM image
 * Burn to a CD and boot your target PC from the CD-ROM drive.

When presented with the inital Ubuntu installation menu, choose to install a LAMP Server. Finish the installation procedure. Reboot the server and sign in

Updating and Configuring
From the prompt, type the following commands... This will update the installation to the latest versions. Sort of like a service pack for Windows.

sudo apt-get update sudo apt-get upgrade

Once that has finished issue the following command

sudo reboot

Once the server has rebooted and you have logged in again, issue another command upgrade to make sure everything is complete.

sudo apt-get upgrade sudo apt-get install php5-cli

This last install will allow you to run PHP applications from the command line. This may be required later. By following most of the guide found here Help:Running_MediaWiki_on_Debian_GNU/Linux I was able to figure out how to get the install working. (I have removed some of the text)

Configure MySQL
Most of all, you need to apply mysql root password. Remember not to use same password for system root and mysql root. This will also clear your command history so that other users cannot get to your password...

mysqladmin -u root password "" history -c

Configure PHP
Next, you need to make sure your php configuration file is configured...

sudo vi /etc/php5/apache2/php.ini

Page down to about 21%, and change the following entry...

from: memory_limit = 8M to:   memory_limit = 20M

Page down a bit further (about 48%) and uncomment the following lines...

extension=mysql.so extension=gd.so

Save and exit out of the VI editor and issue a reboot to Apache...

apache2ctl restart

Get Latest MediaWiki
Next we need to get the latest MediaWiki software from MediaWiki SourceForge page Type the following commands...

cd /var/www sudo wget http://prdownloads.sourceforge.net/wikipedia/mediawiki-1.9.3.tar.gz

or for me in the UK...

sudo wget http://heanet.dl.sourceforge.net/sourceforge/wikipedia/mediawiki-1.9.3.tar.gz

Once downloaded, we need to extract the files...

sudo tar vxfz mediawiki-1.9.3.tar.gz

rename the extracted directory name to wiki

sudo mv mediawiki-1.9.3 wiki

In order to configure the wiki you have to make the config subdirectory writable by the web server.

cd /var/www/wiki sudo chmod a+w config

Continue Configuration
Navigate your browser to http://server_ip_address/wiki and continue with the installation. If you don't know your IP address, type the following...

ifconfig

Pay good attention for "Checking environment..." in MediaWiki installation script. This can solve a lot of problems for your MediaWiki successful installation. Fill out the configuration form and continue.

Once configuration is done you'll need to move the created LocalSettings.php to the parent directory. For added safety you can then remove the config subdirectory entirely.

cd /var/www/wiki/config/ sudo mv LocalSettings.php .. cd .. sudo rm -rf config

And navigate your browser to http://server_ip_address/wiki to see your new wiki.

Done! You now have a working Wiki!!

=Wikimedia Database Dump= One use for your new Wiki is to have an offline cache of the current Wikimedia website.

To do this, you'll need to complete the following steps...

mysql -u root -p enwiki truncate page; truncate revision; truncate text; set sql_log_bin = 0; quit

This clears the current 'default' pages database tables ready for the dump.

Download the latest version of the Wiki Database dump...

cd /home sudo wget http://download.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles.xml.bz2

This will download only the current articles, without any history, discussions or user information. Current compressed size as of September 2006 is about 1.6Gb. The download may take a while depending on your connection speed.

From here, you now have two choices...

Import Method 1
The first one is to use the really slow, but built-in import script.

cd /home bunzip2 -dc enwiki-latest-pages-articles.xml.bz2 | php /var/www/wiki/maintenance/importDump.php

This will take about 10 days or so to complete.

Import Method 2
This requires a little more work, but is about 10 times faster. First, we need to install the Java runtime environment...

sudo vi /etc/apt/sources.list

Find the following lines...


 * 1) deb http://archive.ubuntu.com/ubuntu/ dapper universe
 * 2) deb-src http://archive.ubuntu.com/ubuntu/ dapper universe

add "multiverse" to the end of both lines and remove the # from the begining. Save and exit out of VI editor, then type the following...

cd /home sudo apt-get update sudo apt-get install sun-java5-bin sudo wget http://download.wikimedia.org/tools/mwdumper.jar

The last command downloads the tool we are going to use to dump the databases. Once you have the last package downloaded issue the following command...

java -Xmx200M -server -jar mwdumper.jar --format=sql:1.5 enwiki-latest-pages-articles.xml.bz2 | mysql -u root -p enwiki

This will start the database import, it will take a couple of days.