Manual:Running MediaWiki on Red Hat Linux

Introduction
This article gives detailed instructions for people who want to run MediaWiki on Red Hat Enterprise Linux or a RHEL-rebuild distribution such as CentOS or Oracle Linux.

Prerequisites: Quick Installation of Apache, MySQL and PHP
The major difficulties to installing MediaWiki lie in the correct installation of Apache, MySQL and PHP. You can install the three packages separately from your Red Hat or via any third party compilation and packaging effort, with a good tutorial on setting up a so-called LAMP environment.

Otherwise, you can use the xampp which contains all three of these, properly configured for use by MediaWiki. See apachefriends.org FAQ.

Install operating system packages
Since MediaWiki 1.31 PHP ≥ 7.0 is needed and since MediaWiki 1.35 PHP ≥ 7.3 is needed, see Compatibility. These PHP versions are not available in standard Red Hat Enterprise Linux (RHEL) 7 repositories, so you have to use Software Collections ('sclo') to install PHP ≥ 7. Please note that these only exist for 64bit (x86_64) RHEL; 32bit RHEL7 does not officially exist anyway.

For Red Hat Enterprise Linux version 7 with sclo: use the mysql fork 'mariadb' instead of mysql:

Keep in mind that when using  from Software Collections ('sclo'), web server's root is under   and not under default. As for, its root is under. yum install centos-release-scl yum install httpd24-httpd rh-php73 rh-php73-php rh-php73-php-mbstring rh-php73-php-mysqlnd rh-php73-php-gd rh-php73-php-xml mariadb-server mariadb

For Red Hat Enterprise Linux version 8: RHEL8 includes PHP 7.2 by default so the standard PHP is fine for MediaWiki 1.31-1.34. For MediaWiki ≥ 1.35, you can switch to the PHP 7.4 stream: dnf module reset php dnf module enable php:7.4 dnf install httpd php php-mysqlnd php-gd php-xml mariadb-server mariadb php-mbstring php-json mod_ssl php-intl php-apcu

Database (MySQL) post-install configuration
For Red Hat Enterprise Linux 7 and 8: Start MariaDB and secure it: systemctl start mariadb mysql_secure_installation

Log into MySQL client: mysql -u root -p

At the database prompt, Create the wiki user: CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED'; Create the database: CREATE DATABASE database_name; For example: CREATE DATABASE wikidatabase; Grant privileges to newly created DB: GRANT ALL PRIVILEGES ON wikidatabase.* TO 'wiki'@'localhost'; FLUSH PRIVILEGES; To confirm that it was created: SHOW DATABASES; To display what has been granted: SHOW GRANTS FOR 'wiki'@'localhost'; exit Remember the 'wiki' password for MySQL that you create here. You will need it when setting up the wiki database.

Autostart webserver and database daemons (services)
Start Apache and MySQL on boot. For Red Hat Enterprise Linux 7 and 8: systemctl enable mariadb systemctl enable httpd For Red Hat Enterprise Linux 7 with sclo: systemctl enable mariadb systemctl enable httpd24-httpd.service

Install MediaWiki tarball ("sources")
You can install MediaWiki directly from the MediaWiki web site (recommended), see below for installing pre-built packages from EPEL.

Download MediaWiki directly (the current version as of this writing, may have changed since) in some directory of your choice. You should have (or create) an ordinary, non-privileged user account on the Red Hat server. Substitute that username in the following command:

Install with a symlink for easy upgrading. Note that the ordinary user account name is substituted into the argument to the "tar" command below. Running as the root user, at the shell prompt, type:

Webserver (Apache) post-install configuration
Setting up Apache can be done in numerous ways according to your preferences. In this example I simply change Apache to look at /var/www by default, so the link to the wiki will be http://server/mediawiki. This is convenient for running more than one site on the server. If you only need mediawiki running on the server, change instances of  below to    (Also it works with:  ). Open  and search for and change these three lines:

DocumentRoot "/var/www" &lt;Directory "/var/www">    <-- this is the SECOND "<Directory" entry, not the 'root' one DirectoryIndex index.html index.html.var index.php

Changing the /var/www to /var/www/mediawiki assumes you did the following:

Also it works with: chown -R apache:apache /var/www/mediawiki Restart Apache

service httpd restart

Firewall configuration
You also want to open ports in your firewall.

On RHEL 7 and 8, use firewall-cmd:

Security (selinux) configuration
On a default Red Hat (or CentOS) install, the selinux package will be installed and enabled. You can check this using this command: getenforce If the command displays "enforcing" then you must either disable selinux (not recommended), or set the correct selinux context for the MediaWiki files, running these commands as root: restorecon -FR /var/www/mediawiki-/ restorecon -FR /var/www/mediawiki You can check for the correct context with ls -lZ /var/www/ The media directories and links should have this context: system_u:object_r:httpd_sys_content_t:s0

(alternative) Disabling security (selinux)
If you are determined to disable selinux (instead of configuring it properly as detailed above), go to and modify config vi config making SELINUX either "permissive" or "disabled."

I also had to create a link to /usr/share/mediawiki-/load.php in my /var/www/mediawiki directory and change the ownership on the /usr/share/mediawiki- directory to apache.apache.

Final comments
And you're good to go. Point a browser at http://servername/mediawiki and follow the instructions.