How to Install MediaWiki on Ubuntu (Linux) Server

MediaWiki is a must-have for any start-up, any fast-paced project, any documentation effort.

MediaWiki vs WordPress

If you are not sure you need a Wiki – or are undecided as to whether WordPress is better suited to managing your content than MediaWiki, then read the article on when and how to use MediaWiki.

This page is about installing MediaWiki on a Linux server (the process is similar for Windows installs).

Pre-Conditions before a MediaWiki Install

Check before you install MediaWiki that you

  1. have a running Linux instance (Ubuntu preferred)
  2. a MySQL Database has been installed on or nearby
  3. the Apache Webserver has been installed

You don’t need to install Php5 – the mediawiki install automatically does that for you.

How to Install MediaWiki (in 7 Steps)

The 7 steps to installing MediaWiki are to

  1. Run command sudo apt-get install mediawiki
  2. Change apache.conf configuration file in /etc/mediawiki
  3. Append the word after Alias onto your URL to access mediawiki
  4. Run command sudo a2enconf mediawiki
  5. Restart Apache2 with sudo service apache2 restart
  6. And visit the URL slash wiki like https://www.build-business-websites.co.uk/wiki

MediaWiki should pop up in your browser (albeit wanting to be configured further). Ensure you are using the HTTPS secure sockets layer (SSL) protocol – see How to Install HTTPS (SSL) onto Apache.

How to Configure MediaWiki

The configuration section is done through the browser. It will walk you through the screens and should

  1. Confirm the language used for the wiki
  2. Perform summary checks on your environment.
  3. Tell you things about image thumbnails and unicode – ignore unless you are a mediawiki pro
  4. Confirm (using green text) that mediawiki can be installed.
  5. Spot the MySQL Database that is already installed.
  6. Ask for a database name – like edu_policy_wiki
  7. Want you to use lowercase for the database name – no hyphens but underscores are okay.
  8. Ask for a prefix for database table names – like edu_policy_
  9. Allow you NOT to use the same account for web access – uncheck the box
  10. Let you enter a new database user and password for the web access
  11. Now continue and you are almost done

It pays to take a couple of extra minutes to configure the Wiki settings for the administrator – his or her e-mail address. Also globally applicable information about the wiki is worth entering.

Adding LocalSettings.php for MediaWiki

MediaWiki is unique in that it gives you a settings file (containing passwords and all) – and it wants you to add this configuration file into the below server folder. It does this to enable a simple web configuration process, but wants you to prove you have the necessary access.

Also your next mediawiki install can be as simple as placing a viable LocalSettings.php file in the right location.

Adding LocalSettings.php for MediaWiki

Here is an example LocalSettings.php file which you need to add to the /etc/mediawiki folder.

On Ubuntu there is a link in the /usr/share/mediawiki/LocalSettings.php that points to /var/lib/mediawiki/LocalSettins.php which is itself a link pointing to /etc/mediawiki/LocalSettings.php – ignore all this and put the file into /etc/mediawiki.

What is the Admin Account Username for MediaWiki?

A common problem is trying to Log In as the administrator account for the first time. It fails when you use your e-mail address, your server account name, default names like admin, Admin, administrator, User. And there is nothing helpful in LocalSettings.php – worse still if you click “forgot password” it wants your username so no joy there – what’s the problem?

When you entered your Real Name like “John Smith” – mediawiki takes that as the username! It confuses first timers as no one expects a SPACE in the user name.

The solution is to enter your real name with the correct CAPS as mediawiki is case sensitive.

mediawiki login details are in the database

If you can’t find your username anywhere log into MySQL as the root user with the following
mysql -u root -p

Now from the MySQL command line interface (interpreter) you type in these SQL statements.

show databases;
use database DB_NAME_PREFIX_wiki;
show tables;

Finally once you have pinpointed the table name in the form PREFIX_user you can do a select star.

select * from bbw_user;

Now at last the username is right there.

Changing Password in MediaWiki Database

If you can’t get the “forgot password” e-mail sent (or indeed received) – a simple option is to change the password right in the database mediawiki user table. Check that the user_id is indeed 1. It should be.

Execute this SQL update statement.

UPDATE user SET user_password = MD5( CONCAT( user_id, '-', MD5( 'IWillNotForgetThisPassword' ) ) ) WHERE user_id =1

MediaWiki Install Summary

I hope you have enjoyed setting up mediawiki – I have tried to cover the main points – let me know if it helped or if something is missing or incorrect.

Leave a Reply

Your email address will not be published. Required fields are marked *