How to Install MediaWiki on Ubuntu 16.04

r00t October 28, 2017

Install MediaWiki on Ubuntu 16.04

In this tutorial we’ll learn how to install MediaWiki on Ubuntu 16.04. We will also install and configure its prerequisites. Mediawiki is a free and open source software package written in PHP, developed by the Wikimedia Foundation. Mediawiki runs on many sites like Wikipedia, Wiktionary and Wikimedia Commons. Mediawiki also called a wiki engine is software which permits users to create and edit webpages using a web browser.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install MediaWiki on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing LAMP on Ubuntu 16.04.

You should check out this LAMP stack install tutorial for Ubuntu 16.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that Mediawiki relies on:

apt-get install php7.0-mysql php-xml php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0 imagemagick php7.0-intl php7.0-gd php7.0-mbstring

Step 3. Installing Mediawiki.

First, you will need to download the latest version of Mediawiki from here:

tar -xvzf mediawiki-1.29.1.tar.gz
mv /opt/mediawiki-1.29.1/ /var/www/html/mediawiki

Once it is done, set the owner permission for Apache root directory:

chown www-data:www-data -R /var/www/html/mediawiki

Step 4. Configure Database for MediaWiki.

Next, we need to create a database for the MediaWiki installation:

mysql -uroot -p

Run the following command to create a database for MediaWiki:

GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password';
flush privileges;

Step 5. Configure Apache for Mediawiki.

Once database is configured, you will need to configure Apache for Mediawiki. So, you will need to create new virtual host file for Mediawiki:

touch /etc/apache2/sites-available/mediawiki.conf
ln -s /etc/apache2/sites-available/mediawiki.conf /etc/apache2/sites-enabled/mediawiki.conf
nano /etc/apache2/sites-available/mediawiki.conf

Add the following lines:

<VirtualHost *:80>
DocumentRoot /var/www/html/mediawiki/
<Directory /var/www/html/mediawiki/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

Save and close the file and reload Apache for the above changes to take effect:

a2ensite mediawiki.conf
systemctl reload apache2

Step 5. Accessing MediaWiki Web Installation.

Now you can access the MediaWiki web install wizard in your browser by entering the domain name or http://your_ip/ to continue your MediaWiki installation.

Install MediaWiki on Ubuntu 16.04

Congratulation’s! You have successfully install and configured MediaWiki on your Ubuntu 16.04 server. Thanks for using this tutorial for installing MediaWiki open source wiki on Ubuntu 16.04 LTS (Xenial Xerus) system.

The Tags:

Leave a Comment

Comments are closed.