// Tutorial //

How To Install MediaWiki on Ubuntu 12.04

Published on September 5, 2012
Default avatar
By Etel Sverdlov
Developer and author at DigitalOcean.
How To Install MediaWiki on Ubuntu 12.04
Not using Ubuntu 12.04?Choose a different version or distribution.
Ubuntu 12.04

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

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.

Setup

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:

FLUSH PRIVILEGES;
exit;

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!”

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

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up
About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?
10 Comments

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

I must have done something wrong. After all is done my http://ip_address/mediawiki/index.php does not work. It says can’t find /mediawiki/index.php. What did I do wrong?

another update the url is now… curl -O http://releases.wikimedia.org/mediawiki/1.19/mediawiki-1.19.20.tar.gz

or if 1.22 works… as jeffcogs tested? in 2013? that link is now… curl -O http://releases.wikimedia.org/mediawiki/1.22/mediawiki-1.22.0.tar.gz

I’ve installed it correctly, put the LocalSettings in the folder with the index.php, but the only thing i get is a white page. when i insert ini_set(“display_errors”, 1); in the index.php i get this:

Warning: require_once(/etc/mediawiki/LocalSettings.php): failed to open stream: Permission denied in /etc/mediawiki/includes/WebStart.php on line 136 Fatal error: require_once(): Failed opening required ‘/etc/mediawiki/LocalSettings.php’ (include_path=‘.:/usr/share/php:/usr/share/pear’) in /etc/mediawiki/includes/WebStart.php on line 136

I’m really not a pro with this things and would welcome any help of you. Additional Information: I’ve installed in Ubuntu 12.04

Ok mea culpa. My friend named his server with a lot of leet speek and therefor I had some typos within the name. Sorry my fault. Disregard my last question.

Hey, I tried to follow your tutorial, but I’m lost at a special point. I’ll try to install the mediawiki in a local area on my server and I don’t know how to identify my domain. Maybe my brain is a little bit slow today, but I can’t see any solution. Any ideas how to find out? As a little addition it is not my network, I was pleased to help a little bit there.

@sarmad: What’s the output of <pre>ls /var/www</pre>?

When scp LocalSettings.php into /etc/mediawiki/mediawiki-1.22, browser cannot access to http://localhost/mediawiki/mediawiki-1.22.0/ (show nothing) Any hint?

Fixed, used FileZilla and uploaded MediaWiki from my pc

I’m stuck at the file download, at the curl command. I’ve tried the new link posted by @jeffcogs as well. As soon as I run it I get random and meaningless code. It might be me… I just installed LAMP… not sure if I missed anything. Thanks for any help in advance!

@jeffcogs: Nice catch, I’ll update the article!