How to Install MediaWiki with PHP 7 on an Ubuntu 18.04 VPS or Dedicated Server

What is MediaWiki?

MediaWiki is basically a software by wiki which is totally free and open-source. It currently runs on many famous websites such as Wikipedia, Wiktionary and Wikimedia Commons. MediaWiki is written in PHP.

Its function is to store the contents into a database. Assuming you have VPS hosting or dedicated server hosting, let’s get started!

The Requirement for MediaWiki 1.30.0

  1. You will require MariaDB 5.1, SQLite 3, MySQL 5.0.2 or PostgreSQL 9.0 or later;
  2. And Apache web server 2.0 or higher compiled with the mod_rewrite module;
  3. And finally, you will need the PHP 5.5.9 or higher, with these extensions enabled: mbstring, JSON, Intl, curl, MySQL and GD PHP

Step 1:
Installing Apache server

First things first, on your virtual server you will have to install and configure Apache.

$ sudoapt-get install apache2

Step 2:
Server OS packages update

You will have to check if the server OS packages are updated to get started with the installation.

$ sudo apt-get update 
$ sudo apt-get upgrade

Step 3:
Package installation

Then you have got to install all the required packages.

$ sudo apt-get install imagemagick php7.0-intl php7.0-curl php7.0-gd php7.0-mbstring php7.0-mysql mysql-server php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0

Step 4:
Enabling the Apache rewrite module

You will have to make sure the Apache rewrite module is enabled.

$ sudo a2enmod rewrite

Step 5:
Restarting the Apache

Once you have enabled the Apache rewrite module you have got to restart the Apache services.

$ sudo service apache2 restart

Step 6:
MediaWiki installation

In this step, you have got visit https://www.mediawiki.org/wiki/download and then download the latest version of MediaWiki available here. Download it to the /opt/ directory on the server.

$ cd /opt/
$ sudo wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz
$ sudo tar -xvzf mediawiki-1.31.0.tar.gz
$ sudo mv /opt/mediawiki-1.31.0/ /var/www/html/mediawiki

You will have to set up a proper ownership so that all the files are readable by the server.

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

Then you have got to create a new MySQL database and user.

mysql -u root -p
mysql> SET GLOBAL sql_mode='';
mysql> CREATE DATABASE mediawiki;
mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'your-password';
mysql> GRANT ALL PRIVILEGES ON mediawiki.* TO 'newuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

The ‘your-password’ next to IDENTIFIED BY is your password. Feel free to change it and type in a password of your choice.

Next, in Apache, you will have to create a new virtual host directive. For instance, on your virtual server, create a new Apache configuration file, say ‘mediawiki.conf’.

$ sudo touch /etc/apache2/sites-available/mediawiki.conf
$ sudo ln -s /etc/apache2/sites-available/mediawiki.conf /etc/apache2/sites-enabled/mediawiki.conf
$ sudo vi /etc/apache2/sites-available/mediawiki.conf

Once you have done this, add the following lines by pressing “i” to insert and press Esc button and type :wq to save and exit the editor.

<VirtualHost *:80>
ServerAdmin admin@your-domain-name.com
DocumentRoot /var/www/html/mediawiki/
ServerName your-domain-name.com
ServerAlias www.your-domain-name.com
<Directory /var/www/html/mediawiki/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/your-domain-name.com-error_log
CustomLog /var/log/apache2/your-domain-name.com-access_log common
</VirtualHost>

Then you have got to remove the file, i.e., OOO-default.conf.

$ sudo rm /etc/apache2/sites-enabled/000-default.conf

Now in order to save the changes and for them to take effect, you have got to restart the Apache web server.

$ sudo service apache2 restart

In any browser of your choice visit http://your-domain-name.com. There you will find the hyperlink saying ‘set up the wiki’. Click on ‘set up the wiki’.

This will take you to the installation screen.

Firstly you will have to select your language and Wiki language. Then clicking on Continue will take you to the next page.

There you will have to enter the following information if all the requirements are met and then click on the ‘Continue’ button.

 How to install MediaWiki in VPS

The next step will require some database configuration. Under “Database type” select MySQL. Then write “localhost” under Database host.

Then you have to go to fill the rest of the information according to the database that you created in the first step of this tutorial. Click on the “Continue” button once you have successfully entered all the correct information.

You will be taken to the next page where you have got to select:

Storage engine: InnoDB

 How to install MediaWiki in VPS

Once you have done this, click on the ‘Continue’ button.

Then you will have to enter the name of Wiki. This name will appear in the title bar of the browser.

Create an administrator account. Once you have done all this, you are all set to install Wiki.

 How to install MediaWiki in VPS

You can add the following lines at the bottom of the LocalSettings.php file if you hate waiting and want to speed up the installation process.

$ sudo vi /var/www/html/mediawiki/LocalSettings.php

# Speed improvements
$wgUseGzip = true;
$wgUseFileCache = true;

# Performance settings
$wgDisableCounters = true;
$wgMiserMode = true;

You will also have to set a proper ownership for the LocalSettings.php configuration file.

$ sudo chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php

This wraps up our installation process by successfully installing MediaWiki on your server.

 How to install MediaWiki in VPS

Finally, you have successfully installed Mediawiki, We hope our article helped you :).

Check out these top 3 VPS services:

HostArmada
$1.79 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Edit PHP Settings in Apache on an Ubuntu 18.04 VPS or Dedicated Server

This is a detailed guide on editing and configuring most PHP settings running on
4 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Install the LEMP (Linux, Nginx, MySQL, PHP) Stack on an Ubuntu 18.04 VPS or Dedicated Server

This tutorial walks you through the process of installing Nginx, MySQL, and PHP
4 min read
Mark Armistead
Mark Armistead
Author

How To Install Apache, MySQL & PHP on an Ubuntu 18.04 VPS or Dedicated Server

This article shows users how to setup PHP, Apache web server and MySQL database
4 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Set Up WordPress Multisite on Ubuntu 18.04 with Apache Web Server

In this tutorial, we explain how to set up WordPress multisite on an Ubuntu 18.0
3 min read
Idan Cohen
Idan Cohen
Marketing Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top