How to install MediaWiki on CentOS/Fedora

Status: This OS is no longer supported

This article, “How to install MediaWiki on CentOS/Fedora,” covers a version of CentOS that reached end of life (EOL) and is no longer supported. As such, this guide is no longer maintained. As such, if you are currently operating a server running CentOS 6, we highly recommend contacting RoseHosting’s fully managed support to upgrade or migrate to a supported version of AlmaLinux.

 
In this article, we will guide you on how to install MediaWiki on a CentOS/Fedora VPS. MediaWiki is a free, web-based wiki platform written in PHP, with powerful capabilities. It is one of the most popular applications of this type in the world.

You can easily install MediaWiki in under 10 minutes. You should have a web server (Apache), PHP, and a database server (MySQL) installed on your Linux VPS to run MediaWiki.

Step-by-step Guide

1. Go to MediaWiki’s official website and download the latest version of the platform:

# wget http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.2.tar.gz

2. Now you should extract the downloaded tar.gz file in your Apache Document Root directory:

# tar -xzvf mediawiki-1.19.2.tar.gz -C /var/www/html

3. To find out Apache’s document root directory, execute:

# grep '^DocumentRoot' /etc/httpd/conf/httpd.conf

4. Rename the extracted directory. In our case, we will rename the directory from ‘mediawiki-1.19.2’ to ‘mediawiki’:

# mv /var/www/html/mediawiki-1.19.2 /var/www/html/mediawiki

5. 

Ensure that the Apache user, in our case ‘apache’, owns all WikiMedia files and directories:
# chown -R apache:apache

6. Finally, MediaWIki requires MySQL user and database, so let’s create them by executing the following commands:

# echo "CREATE DATABASE wikidb;" | mysql -u root -p
# echo "CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'PASSWORD_HERE';" | mysql -u root -p
# echo "GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost';" | mysql -u root -p
# echo "FLUSH PRIVILEGES;" | mysql -u root -p

Congratulations!

This step completes the command-line installation. You can complete the rest using a web browser.All you need to do is open http://yourdomain.tld/wiki and follow the on-screen instructions.  With this, MediaWiki will check if your server meets the requirements for installing and running the software. Additionally, the system will prompt you to set your MySQL user and database information, as well as other general settings. At the end of the installation, the MediaWiki installer generates a ‘LocalSettings.php’ file, which contains all the necessary configuration settings. You will need to copy the code from the screen and paste it into a file called ‘LocalSettings.php’ in the ‘/var/www/html/wiki’ directory. Execute:
 
# nano /var/www/html/wiki/LocalSettings.php

Paste the code and save the file. That’s all.

Finally, in case you liked this post, please share it with your friends or leave a reply below. Thanks.

1 thought on “How to install MediaWiki on CentOS/Fedora”

Leave a Comment