Manual:Running MediaWiki on Red Hat Linux

From MediaWiki.org
Jump to navigation Jump to search
Installation guides
FreeBSD
GNU/Linux
- ALT Linux
- Arch Linux
- Damnsmalllinux
- Debian or Ubuntu
- Fedora
- Gentoo
- Mandriva
- Red Hat Enterprise Linux
- Slackware
Mac OS X
NetWare
Solaris
- Solaris 11 / opensolaris
- Solaris 10
Windows
- Windows Server 2016
on a stick
- Uniform Server
- XAMPP
Sourceforge.net

Introduction[edit]

This article gives detailed instructions for people who want to run MediaWiki on a Red Hat Enterprise Linux or CentOS platforms.

Prerequisites: Quick Installation of Apache, MySQL and PHP[edit]

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[edit]

Since MediaWiki 1.27 PHP >= 5.5 is needed, see Compatibility#PHP. This PHP version is not available in standard Red Hat Enterprise Linux (RHEL) repositories, so you have to use Software Collections ('sclo') to install PHP >= 5.5. Please note that these only exist for 64bit (x86_64) RHEL, but not for 32bit RHEL6 (32bit RHEL7 does not officially exist anyway).

For 64bit Red Hat Enterprise Linux version 6: Using the Red Hat package system:

yum install httpd php php-mysql php-gd php-xml mysql-server mysql

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

yum install httpd php php-mysql php-gd php-xml mariadb-server mariadb php-mbstring

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

Keep in mind that when using httpd24 from Software Collections ('sclo'), web server's root is under /opt/rh/httpd24/root and not under default /var/www/html. As for php55, its root is under /opt/rh/php55/root.

yum install centos-release-scl
yum install httpd24-httpd php55 php55-php php55-php-mbstring php55-php-mysqlnd php55-php-gd php55-php-xml mariadb-server mariadb 

Database (MySQL) post-install configuration[edit]

For Red Hat Enterprise Linux 6: Start MySQL and secure it:

service mysqld start
mysql_secure_installation

For Red Hat Enterprise Linux 7: 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)[edit]

Start Apache and MySQL on boot.

For Red Hat Enterprise Linux 6:

chkconfig httpd on
chkconfig mysqld on

For Red Hat Enterprise Linux 7:

systemctl enable mariadb
systemctl enable httpd

For Red Hat Enterprise Linux 7 with sclo:

systemctl enable mariadb
systemctl enable httpd24-httpd.service

Download MediaWiki[edit]

Install MediaWiki tarball ("sources")[edit]

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:

cd /home/username
wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.1.tar.gz

Download the GPG signature for the tarball and verify the tarball's integrity:

wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.1.tar.gz.sig
gpg --verify mediawiki-1.31.1.tar.gz.sig mediawiki-1.31.1.tar.gz

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:

cd /var/www
tar -zxf /home/username/mediawiki-1.31.1.tar.gz
ln -s mediawiki-1.31.1/ mediawiki

(alternative) Install MediaWiki as an RPM from EPEL[edit]

As an alternative to the above recommended install, EPEL maintains a pre-built package (.rpm file). The repository is located here: Fedora Project Extra Packages for Enterprise Linux (EPEL). This package may be one or more versions behind the current stable MediaWiki branch. However, many RHEL and CentOS users find EPEL is a good source for packages not included in the base system.

First, configure your Red Hat (CentOS) installation to recognize the EPEL package repository, following these instructions: add the EPEL repository as a source for your package manager.

List the available EPEL MediaWiki packages:

yum list 'mediawiki*'

or, if you want descriptions of each package

yum info 'mediawiki*'

Then install those that you choose with a command like

yum install packagenames go here, blank separated

Configure[edit]

Webserver (Apache) post-install configuration[edit]

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 /var/www below to /var/www/mediawiki (Also it works with: /var/www/mediawiki-1.31.1). Open /etc/httpd/conf/httpd.conf and search for and change these three lines:

DocumentRoot "/var/www"
<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:

cd /var/www
ln -s mediawiki-1.31.1/ mediawiki
chown -R apache:apache /var/www/mediawiki-1.31.1 

Also it works with:

chown -R apache:apache /var/www/mediawiki

Restart Apache

service httpd restart

Firewall configuration[edit]

You also want to open ports in your firewall using

 system-config-firewall-tui

Enable both the https and http services (follow the instructions of the configuration interface).

Add details (install system-config-firewall-tui and enable services)

yum install system-config-firewall-tui

firewall-cmd --add-service=http
firewall-cmd --add-service=https

Security (selinux) configuration[edit]

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-1.31.1/
 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)[edit]

If you are determined to disable selinux (instead of configuring it properly as detailed above), go to

cd /etc/selinux 

and modify config

vi config

making SELINUX either "permissive" or "disabled."

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

Final comments[edit]

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

References[edit]

https://secure.php.net/manual/en/install.apache2.php