How to install MediaWiki on an Ubuntu 16.04 VPS

In this tutorial we are going to provide you with step by step instructions on how to install MediaWiki on an Ubuntu 16.04 VPS. MediaWiki is an open-source wiki software written in PHP.

At the time of writing this tutorial, the latest stable version of MediaWiki is 1.27.1 and it requires:

  • PHP 5.5.9 or higher (preferably the latest), with mbstring, JSON, curl, Intl, mysql and GD PHP extensions enabled. ImageMagick or GD is required for image thumbnailing
  • MySQL 5.0.2, MariaDB 5.1, SQLite 3 or PostgreSQL 9.0 sau o versiune ulterioară
  • Apache web server 2.0 or higher compiled with mod_rewrite module.

This install guide assumes that Apache is already installed and configured on your virtual server.

Let’s start with the installation. Make sure your server OS packages are fully up-to-date:

apt-get update 
apt-get upgrade

Install the required packages:

apt-get install imagemagick php7.0-intl php7.0-curl php7.0-gd php7.0-mbstring php7.0-mysql

Enable Apache rewrite module if it is not already done so:

a2enmod rewrite

Restart the Apache service for the changes to take effect:

service apache2 restart

Install MediaWiki

Download the latest version of MediaWiki available at to the /opt/ directory on the server:

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

All files have to be readable by the web server, so set a proper ownership:

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

Create a new MySQL database and user:

mysql -u root -p
mysql> SET GLOBAL sql_mode='';
mysql> CREATE DATABASE wikidb;
mysql> CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'y0uR-pa5sW0rd';
mysql> GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost';
mysql> quit

Do not forget to replace ‘y0uR-pa5sW0rd’ with a strong password.

Create a new virtual host directive in Apache. De exemplu, create a new Apache configuration file named ‘mediawiki.conf’ on your virtual server:

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

Apoi, add the following lines:

<VirtualHost *:80>
ServerAdmin [email protected]
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

Remove the 000-default.conf file:

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

Restart the Apache web server for the changes to take effect:

service apache2 restart

Open in your favorite web browser, click on the ‘set up the wiki’ hyperlink and follow the easy instructions on the install screen inserting the necessary information as requested:

Select your language and the Wiki language. Pe pagina următoare, click ‘continue’ if all requirements are met, then enter the following information:

Database Host: localhost
Database name: wikidb
Database username: wikiuser
Database password: y0uR-pa5sW0rd   // change this password with your actual password

Click ‘Continue’. On the next page select:

Storage engine: InnoDB
Database character set: UTF-8

Click ‘Continue’. Enter the name of Wiki which will appear in the title bar of the web browser and other places, create an administrator account and install the Wiki.

In order to improve the speed and performance of your MediaWiki installation, add the following lines at the end of the LocalSettings.php file :

vi /var/www/html/mediawiki/LocalSettings.php
# Speed improvements
$wgUseGzip = true;
$wgUseFileCache = true;

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

Set a proper ownership of the LocalSettings.php configuration file:

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

That is it. MediaWiki has been installed on your server.

Log in to the MediaWiki administration back-end and start creating new content, add user accounts, extensions etc.

mediawiki back-end


lasă un răspuns