How to Install MediaWiki on CentOS 7 or RHEL 7 Server

Overview :

Mediawiki is a free open source wiki software which is written in PHP and allows the visitors of your website to edit the pages and it also stores the version of history of editable pages in its database like MySQL or MariaDB.

A wiki can be defined as Content Management System (CMS) or a website whose contents are editable from the web browser and its text is written using simplified markup language (known as ‘wiki markup’) or a rich-text editor. A wiki is differ from a blog or such system as the content is posted and created without any defined author and owner of the post.

In this post we will discuss the installation steps of MediaWiki 1.24 on CentOS 7 and RHEL 7

Step:1 Install the prerequisite OS packages using yum command

For mediawiki installation on Linux we must first install Web server (Apache) , PHP and Database ( MySQL / MariaDB ). If they are not installed on your system , please use the below command to install :

[[email protected] ~]# yum install httpd php php-mysql php-gd mariadb-server php-xml php-intl mysql
Step:2 Start the Web Server and Database Service
[[email protected] ~]# systemctl restart httpd.service ; systemctl enable httpd.service
[[email protected] ~]# systemctl start mariadb ; systemctl enable mariadb
Step:3 Create Mediawiki Database

Connect to your database using mysql command and execute the following commands

[[email protected] ~]# mysql -u root -p

mysql> CREATE DATABASE mediawiki_db;

mysql> GRANT ALL PRIVILEGES ON mediawiki_db.* TO 'wiki_user'@'localhost' IDENTIFIED BY '[email protected]@123#' WITH GRANT OPTION;


mysql> exit;


Replace the database name, user name and its credentials in above commands as per your setup.

Step:4 Download MediaWiki 1.24.2 with wget command

At the time of writing this article, latest version of Mediawiki 1.24.2 was available. Please refer this link to get Latest version of MediaWiki

[[email protected] ~]# wget

Untar the downloaded file using below tar command.

[[email protected] ~]# tar -zxpvf mediawiki-1.24.2.tar.gz

Move mediawiki-1.24.2 to its document root (/var/www/html/mediawiki/)

[[email protected] ~]# mv mediawiki-1.24.2 /var/www/html/mediawiki
Step:5 Set the required permissions on mediawiki directory
[[email protected] ~]# chown -R apache:apache /var/www/html/mediawiki/
[[email protected] ~]# chmod 755 /var/www/html/mediawiki/
[[email protected] ~]#
Step:6 Now start the MediaWiki web based installation

Before starting the Installation , please check followings

If your system is running behind the iptables / firewall , then use below commands to open 80 port for mediawiki.

[[email protected] ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
[[email protected] ~]# firewall-cmd --reload
[[email protected] ~]# iptables-save | grep 80
-A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
[[email protected] ~]#

If Selinux is enable on your Linux box , then set the following Selinux rules on mediawiki folder

[[email protected] ~]# getenforce
[[email protected] ~]# restorecon -FR /var/www/html/mediawiki/

Now Open the web browser type http://<IP_Address_of_System>/mediawiki


Replace the ip address as per your setup . Click on “Set up the wiki

Define the Language for MediaWiki


Click On Continue

MediaWiki Environment Setup Check :


Click On Continue…

Define the Mediawiki database, database user name and Password.


MediaWiki Database Settings


Define Name of Wiki and its Administrator Account


Click on Continue to finish the installation


MediaWiki installation is completed. Now Download “LocalSettings.php” file and placed it under the mediawiki document root (/var/www/html/mediawiki/ )


Now visit the Main page ( and Login Admin Panel of Mediawiki


Click on Log In . Enter the Admin Credentials that we have set during the installation.



Hope you enjoy the installation steps. Please share you comments and feedback on this article.

10 thoughts on “How to Install MediaWiki on CentOS 7 or RHEL 7 Server”

  1. This information made me feel better.Its tremendous to learn the basic installation of media wiki.Hope all will refer this to complete their successfull installation of mediawiki

  2. On my CentOS 7 system, I had to substitute mysqld with mariadb when I got “Nothing to do” (not found) : ie. yum install mariadb-server – hope this helps somebody. Thanks for this helpful reference

  3. Is the process of installing mediawiki the same for shared hosting and cloud hosting platforms? I followed your tutorial and another tutorial (‘’ ) to install it. However, when i try to access the domain i am getting 500 internal server error.

  4. If we want to do offline installation, then can we download the .tar file of mediawiki on some other system and then transfer to the CentOS using USB?

    1. Hi Raza,

      Yes, You can do the offline installation.

      1) Download mediawiki tar file and transfer it to target system
      2) Use ‘yum downloader’ to download all dependencies and make a tar file and transfer it to target system

  5. This is a really helpful.

    I am trying to create a docker file with these set of steps and create an image out of it so that this can be deployed anywhere.

    Can someone please help with they have tried this approach.

    Anurag B.

Leave a Reply

Your email address will not be published. Required fields are marked *