We’ll show you how to install MediaWiki on Ubuntu 16.04. MediaWiki is an open-source wiki software written in PHP. Installing MediaWiki on Ubuntu 16.04 is an easy task, just follow the steps in this tutorial and you should have MediaWiki installed on Ubuntu 16.04 in less than 10 minutes. Installing MediaWiki on Ubuntu 16.04, is fairly easy task, just follow the steps bellow and you should have MediaWiki installed on your Ubuntu server in less then 10 minutes.
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 or later
- Apache web server 2.0 or higher compiled with mod_rewrite module.
Table of Contents
1. Install Apache server
This install guide assumes that Apache is already installed and configured on your virtual server.
2. Update your server OS Packages
Let’s start with the installation. Make sure your server OS packages are fully up-to-date:
apt-get update apt-get upgrade
3. Install the required packages
Install the required packages:
apt-get install imagemagick php7.0-intl php7.0-curl php7.0-gd php7.0-mbstring php7.0-mysql
4. Enable Apache Rewrite Module
Enable Apache rewrite module if it is not already done so:
a2enmod rewrite
5. Restart Apache service
Restart the Apache service for the changes to take effect:
service apache2 restart
6. Install MediaWiki
Download the latest version of MediaWiki available at https://www.mediawiki.org/wiki/Download to the /opt/ directory on the server:
cd /opt/ wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.1.tar.gz 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> FLUSH PRIVILEGES; mysql> quit
Do not forget to replace ‘y0uR-pa5sW0rd’ with a strong password.
Create a new virtual host directive in Apache. For example, 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
Then, add the following lines:
<VirtualHost *:80> ServerAdmin admin@your-domain.com DocumentRoot /var/www/html/mediawiki/ ServerName your-domain.com ServerAlias www.your-domain.com <Directory /var/www/html/mediawiki/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/your-domain.com-error_log CustomLog /var/log/apache2/your-domain.com-access_log common </VirtualHost>
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 http://your-domain.com 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. On the next page, 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.
Of course, you don’t have to do any of this if you use one of our MediaWiki VPS Hosting services, in which case you can simply ask our expert Linux admins to install MediaWiki for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
I did all of the steps but I get an Error 403 Forbidden nginx/1.10.0 (Ubuntu) error
Please check for ownership and permissions of your MediaWiki installation path.
You should be able to fix the permission problem using:
chown www-data:www-data -R /var/www/html/mediawiki
Replace www-data with your nginx user and /var/www/html/mediawiki with the actual path to your MediaWiki installation.
how to enable ldap authentication
More information about this you can find at: https://www.mediawiki.org/wiki/Extension:LDAP_Authentication
I guess you forgot MySQL installation procedure . Please, do a double check on that.
This tutorial assumes that MySQL server is already installed. If not, install it using:
sudo apt-get install mysql
I have 500 Internal Server Error after having /var/www/html/mediawiki. The official website mention to change the permission.
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
But I still have the same error. Do you have any clue on what I can do?
Make sure you set a proper ownership of MediaWiki files/directories using:
chown www-data:www-data -R /var/www/html/mediawiki
also php installation step is missing. i am doing this on a vanilla ubuntu 16.04 desktop choosing defaults fro package installasion. apparently php is not installed by default on this 16.04. apt install php7.0
the reason for this is when i start i get the php page that says “this is the main entrypiont for mediawiki” no php… problem solved by isntalling php
This tutorial assumes that PHP is already installed. If not, install it using:
apt-get install php7.0