We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Install MediaWiki on Ubuntu 12.04

Posted Sep 5, 2012 37.6k views Applications CMS Ubuntu

About MediaWiki

MediaWiki is a free open source wiki program that allows users to create their own personal wiki sites. Originally built for Wikpedia, MediaWiki is written in PHP and uses a backend database, like MySQL, to store its data.


The steps in this tutorial require the user to have root privileges. You can see how to set that up in the here Initial Server Setup Tutorial.

Before working with MediaWiki, you need to have LAMP installed on your server. If you don't have the Linux, Apache, MySQL, PHP stack on your server, you can find the tutorial for setting it up Ubuntu LAMP Installation Tutorial.

Once you have the user and required software on the virtual private server, you can start installing MediaWiki!

Install Media Wiki

Because the apt-get package of MediaWiki is very out of date, MediaWiki should be installed from source. We can start off by downloading the latest version:

curl -O http://dumps.wikimedia.org/mediawiki/1.19/mediawiki-1.19.2.tar.gz

After it downloads, untar the package:

tar xvzf mediawiki-*.tar.gz

Move the contents of the MediaWiki directory to a a more convenient location:

sudo mv mediawiki-1.19.2 /etc/mediawiki

Create a symbolic link between the MediaWiki directory and Apache’s document root:

sudo ln -s /etc/mediawiki/ /var/www

And finish up by restarting apache.

sudo service apache2 restart

Create a MySQL User and Database

Although this step is not required for a successful installation of MediaWiki, it is definitely a recommended measure for added security.

During the installation process, you will be asked to supply either a database and associated user for a MediaWiki database or your MySQL root password. MediaWiki uses this information to create the required wiki database and tables.Setting up a dedicated database can be done very quickly and removes the need for sharing the MySQL root information and the associated security risks. We can go ahead and set up the database now:

Log into MySQL on your VPS:

mysql -u root -p

Once you are logged in, create your MediaWiki database. The default name that MediaWiki has in their configuration form is my_wiki, but you can name it whatever you prefer:

create database my_wiki;

Additionally, you will need to provide a user for the new database with the permissions that MediaWiki requires (replace the username and password below with details of your choice):

grant index, create, select, insert, update, delete, alter, lock tables on my_wiki.* to 'wikiuser'@'localhost' identified by 'password';

Finish up by implementing the changes and quitting MySQL:


The next part of the installation needs to be completed through the onscreen instructions located at [domain]/mediawiki/index.php

Set Up MediaWiki

Go through and fill out the Media Wiki Site configuration in the browser.

When you reach the “MySQL settings” section of the setup page, leave the Database Host as localhost and then enter in the MySQL database name and username and password, if you configured them in the previous step. If you did not set up a new user for MediaWiki, write in root for the username and the root password in the password field.

You can leave the “MySQL specific options” section as is.

Once you have finished walking through the the configuration, keep pressing continue until you reach the page that says, “Complete!”


The LocalSettings.php file should start downloading automatically. Make sure that you have downloaded the file before closing out of the page. LocalSettings.php is auto-generated—if you do not have the Local Settings file, you will have to generate it once again by going through all of the MediaWiki setup steps.

Once the file downloads, you should upload it to /etc/mediawiki, or whichever directory contains MediaWiki’s “index.php” file on your virtual server.

You can copy the LocalSettings.php file from your computer to the server, with SCP (Secure Copy), an SSH-based way of transferring files:

scp /path/to/LocalSettings.php [username]@[IP Address]:/etc/mediawiki

After the file is uploaded, you will be able to access your personal wiki at [domain]/mediawiki

See More

This has been a brief overview of how to install MediaWiki. If you have any specific questions about MediaWiki, feel free to ask them in our Q & A Forum

By Etel Sverdlov


Creative Commons License