ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install MediaWiki on CentOS 7

MediaWiki is a free, open source web application written in PHP. It was originally created for Wikipedia but now everyone can use it. It uses MySQL to store its data. MediaWiki is designed to handle very large traffic, about a million requests per day. Pages use MediaWiki's wikitext format which means a user can easily create and modify a Wiki page without having any knowledge of HTML and CSS. MediaWiki has a version control system which means any wiki page can be restored to previous versions. MediaWiki also has an inbuilt system for managing images and multimedia files. MediaWiki also supports caching which increases the speed of the website. Thousands of websites are running MediaWiki, including Wikipedia.

A few notable features of MediaWiki are:

  • Easy navigation, links and shortcuts.
  • File upload and management along with automatic resizing of images.
  • Mathematical formulas using LaTeX syntax, powerful search option.
  • MySQL/MariaDB, PostgreSQL, and SQlite are supported, caching is also available.
  • Access control features and Spam blacklist features are also available.
  • Multilingual support and RSS support.
  • Section editing along with JavaScript based editing toolbar.

Apart from the features mentioned above, MediaWiki has numerous other features. In this tutorial we will learn to install to MediaWiki on CentOS 7.


MediaWiki does not require any special hardware requirements. All the required dependencies will be installed throughout the tutorial. You will only need a root account or sudo access on your server. If you are logged in as non root user, run sudo -i to switch to root user or you can also use sudo command before all administrative commands.

Installing MediaWiki

Before installing any package it is recommended that you update the packages and repository using the following command.

    yum -y update

Once you have your system updated, you can proceed to install the LAMP stack. Start the LAMP installation by installing Apache web server and MariaDB, which is a fork of MySQL using the following command.

    yum -y install httpd mariadb-server mariadb

Since MediaWiki version 1.27, it uses a PHP version greater than 5.5. The YUM repository contains PHP version 5.4 only, hence we will need to use the Webtatic repository to install a version of PHP greater than 5.5. Run the following commands for installing EPEL repository as EPEL repository is required before we install Webtatic repository.

    yum -y install epel-release
    yum -y update
    clean all

Now install Webtatic repository using the following commands.

    rpm -Uvh
    yum -y update
    yum clean all

To install PHP 5.5 and all the required PHP modules, run the following command.

    yum -y install php55w php55w-mysql php55w-xml php55w-intl php55w-gd php55w-mbstring texlive

To install PHP 7.0 and all the required PHP modules, run the following command.

    yum -y install php70w php70w-mysql php70w-xml php70w-intl php70w-gd php70w-mbstring texlive

In athe bove commands, the PHP XML extension is required for MediaWiki to run, PHP Intl extension, for internationalization support and PHP GD for image thumbling. Tex Live is installed for adding inline mathematical formulas in Wiki page.

Make sure that you are using only one of the PHP versions mentioned above. Once you have PHP installed, you can check the version of PHP using the following command.

    php -v

You will likely see the following output for PHP 5.5.

    [root@ip-172-31-31-130 ~]# php -v
    PHP 5.5.38 (cli) (built: Jul 21 2016 12:25:20)
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

For PHP 7.0, you will likely see the following output.

    [root@ip-172-31-31-130 ~]# php -v
    PHP 7.0.12 (cli) (built: Oct 15 2016 19:03:00) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

Make sure that your PHP version is not older than 5.5. Now start Apache web server and enable it to start at boot time using following command.

    systemctl start httpd
    systemctl enable httpd

To start MariaDB and enable it to start at boot time using the following commands.

    systemctl start mariadb
    systemctl enable mariadb

Now run the following commands to secure your MySQL or MariaDB installation.


It will run a small script which which ask you to set a root password for your MariaDB installation. Most of the questions are self explanatory and you should answer yes for all the questions. The output of the command will look as shown below.

    [root@ip-172-31-31-130 ~]# mysql_secure_installation
    /bin/mysql_secure_installation: line 379: find_mysql_client: command not found


In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.

Enter current password for root (enter for none): OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.

Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] y ... Success!

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y ... Success!

By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.

Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] y ... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB installation should now be secure.

Thanks for using MariaDB!

As we have all the dependencies ready we can now create a database to store the data of MediaWiki. MediaWiki can also use a SQLite database to store its data. Using SQLite is not recommended when you have the option to use MySQL or PostgreSQL database as SQLite database is stored in file system as a file, hence it affects the speed of the application. It is recommended to use MySQL/MariaDB to store MediaWiki data.

To create a database we will need to login to MySQL command line first. Run the following command for same.

    mysql -u root -p

This will prompt you for password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your MediaWiki installation.

    CREATE DATABASE mediawiki;

The above query will create a database named mediawiki. For the database you can use any name you prefer in the place of mediawiki. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. Using root user is not recommended for the databases. To create a new database user, run the following query.

    CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'StrongPassword';

The above query will create a user with username wikiuser. You can use any preferred username instead of wikiuser. Replace StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command:;

    GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost';

Now run the following command to immediately apply the changes on the database privileges.


You will see the output similar to this.

    [root@ip-172-31-31-130 ~]# mysql -u root -p
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 11
    Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE mediawiki; Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'StrongPassword'; Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost'; Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)

You can run the following command to check if database has been created.


To check, what permissions has been granted to the user over the database, run the following command.

    SHOW GRANTS FOR 'wikiuser'@'localhost';

You will see output similar to this.

    MariaDB [(none)]> SHOW DATABASES;
    | Database           |
    | information_schema |
    | mediawiki          |
    | mysql              |
    | performance_schema |
    4 rows in set (0.00 sec)

MariaDB [(none)]> SHOW GRANTS FOR 'wikiuser'@'localhost'; +-----------------------------------------------------------------------------------------------------------------+ | Grants for wikiuser@localhost | +-----------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'wikiuser'@'localhost' IDENTIFIED BY PASSWORD '*98AA1D1CBE27FFF36829AE7E604EBEF2C9695BEC' | | GRANT ALL PRIVILEGES ON `mediawiki`.* TO 'wikiuser'@'localhost' | +-----------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)

Exit MySQL prompt by executing exit command. Now as we have our database ready you can now download the MediaWiki using the following command.


You can always check for the link to latest release on the download page. Unpack the package using the following command.

    tar xzf mediawiki-1.27.1.tar.gz

Now move the MediaWiki files to the webroot directory of Apache web server which is /var/www/html. Run the following command to do so.

    mv mediawiki-1.27.1/* /var/www/html

Set appropriate permissions to the Apache process over Apache web root directory using the following command.

    chown -R apache:apache /var/www/html
    chmod -R 755 /var/www/html

Now you can access the website using your favorite browser. Go to http://your-server-IP and you will see following interface.

If you encounter an a message saying Forbidden You don't have permission to access on this server. Then you will have to disable the SELinux of your system. To disable SElinux run the following command.

    setenforce 0

Now restart your Apache server using the following command.

    systemctl restart httpd

To proceed further with the web installation click on set up the wiki link. You will be taken to the web installer. You will be asked about the language to use in the installation and the Wiki language, select your preferred language from drop down menu and click on Continue button to proceed to the next step. Now you will be asked to accept the licence agreement, click Continue to proceed further.

Now you will be asked to provide the details of the database. Select MySQL as the database type, leave localhost in the value of database host. Provide the name of database, in our case it was mediawiki. In the database table prefix, you can provide a random string. If you do so then all the tables of MediaWiki will start using that string. It is useful when you are storing the data of more than one application in single database.

Next provide the username and password of the database user which we have created. Click Continue to proceed further.

Next it will ask you about the database used for web access, leave the option checked. Next it will ask you for the storage engine and character set to use. You can leave the default option check for both of these options.

Next you will be asked about the name of your Wiki, choose any name you prefer. For project namespace you can use the default name of your Wiki. Now you will need to create the administrator account by providing the username, password and administrator email.

Next you will be asked if you wish to configure more options or you want to install the wiki. If you want to explore more options, you can choose Ask me more questions, if you wish to configure these options later, you can choose I'm bored already, just install the Wiki. Click Continue button to proceed further.

In the next interface you will see the Install section, just click on Continue button to begin the installation of MediaWiki, installer will now write the changes to the database. After the installation is done, the installer will generate a file named LocalSettings.php.

The file will be automatically download via your browser. If the file does not download automatically, then you can also click on Download LocalSettings.php link to download again. This file is generated by MediaWiki and contains all the configuration of MediaWiki, it is important to place the installer into the Webroot directory otherwise Wiki will not start. To place the file into Apache web root directory, you can use FTP or SCP, but most easier option will to simply create a new file using terminal and copy and paste the content of the LocalSettings.php into the new file.

A sample LocalSettings.php will have the similar contents as shown below.

    # This file was automatically generated by the MediaWiki 1.27.1
    # installer. If you make manual changes, please keep track in case you
    # need to recreate them later.
    # See includes/DefaultSettings.php for all configurable settings
    # and their default values, but don't forget to make changes in _this_
    # file, not there.
    # Further documentation for configuration settings may be found at:

# Protect against web entry if ( !defined( 'MEDIAWIKI' ) ) { exit; }

## Uncomment this to disable output compression # $wgDisableOutputCompression = true;

$wgSitename = "My Wiki"; $wgMetaNamespace = "My_Wiki";

$wgScriptPath = "";

## The protocol and server name to use in fully-qualified URLs $wgServer = "";

## The URL path to static resources (images, scripts, etc.) $wgResourceBasePath = $wgScriptPath;

## The URL path to the logo. Make sure you change this from the default, ## or else you'll overwrite your logo when you upgrade! $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = true; $wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "apache@"; $wgPasswordSender = "apache@";

$wgEnotifUserTalk = false; # UPO $wgEnotifWatchlist = false; # UPO $wgEmailAuthentication = true;

## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "mediawiki"; $wgDBuser = "wikiuser"; $wgDBpassword = "StrongPassword";

# MySQL specific settings $wgDBprefix = "";

# MySQL table options to use during installation or update $wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

# Experimental charset support for MySQL 5.0. $wgDBmysql5 = false;

## Shared memory settings $wgMainCacheType = CACHE_NONE; $wgMemCachedServers = [];

## To enable image uploads, make sure the 'images' directory ## is writable, then set this to true: $wgEnableUploads = false; #$wgUseImageMagick = true; #$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from $wgUseInstantCommons = false;

$wgShellLocale = "en_US.utf8";

# Site language code, should be one of the list in ./languages/data/Names.php $wgLanguageCode = "en";

$wgSecretKey = "295cb2055ee4b38e1b8f3462e549703437bf7f6f576efde211a0c2ec1069576f";

# Changing this will log out all existing sessions. $wgAuthenticationTokenVersion = "1";

$wgUpgradeKey = "2ace25d296cd5b32";

$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright $wgRightsUrl = ""; $wgRightsText = ""; $wgRightsIcon = "";

$wgDiff3 = "/usr/bin/diff3";

$wgDefaultSkin = "vector"; wfLoadSkin( 'CologneBlue' ); wfLoadSkin( 'Modern' ); wfLoadSkin( 'MonoBook' ); wfLoadSkin( 'Vector' );

# End of automatically generated settings. # Add more configuration options below.

To create a new file, run the following command.

    nano /var/www/html/LocalSettings.php

You can use any editor you like for creation of the file. In above command we have used nano editor. If you do not have nano installed, you can run yum -y install nano.

The above command will create a new file and open it into the editor. Copy the content from the downloaded file and paste it into the new file. Now save the file and exit from editor. Go to the browser and open your website again you will see that your wiki has been installed.


In this tutorial we have learnt to install MediaWiki in CentOS 7. You can now easily install MediaWiki to create a wiki site for personal or professional use. Using MediaWiki is very easy, you can create wiki pages very easily using MediaWiki's wikitext format.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans