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.
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.
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!
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
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
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
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
If you’ve enjoyed this tutorial and our broader community, consider checking out our DigitalOcean products which can also help you achieve your development goals.