Manual:Running MediaWiki on Red Hat Linux

From MediaWiki.org
Jump to: navigation, search


Installation guidesManual:Installation guide
on FreeBSDManual:Running MediaWiki on FreeBSD
on GNU/LinuxManual:Running MediaWiki on Linux
- ALT LinuxManual:Running MediaWiki on ALT Linux
- Arch LinuxManual:Running MediaWiki on Arch Linux
- DamnsmalllinuxManual:Running MediaWiki on Damnsmalllinux
- DebianManual:Running MediaWiki on Debian GNU/Linux
- FedoraManual:Running MediaWiki on Fedora
- GentooManual:Running MediaWiki on Gentoo Linux
- MandrivaManual:Running MediaWiki on Mandriva
- Red Hat Enterprise LinuxManual:Running MediaWiki on Red Hat Linux
- SlackwareManual:Running MediaWiki on Slackware Linux
- UbuntuManual:Running MediaWiki on Ubuntu
on Mac OS XManual:Running MediaWiki on Mac OS X
on NetWareManual:Running MediaWiki on NetWare
on SolarisManual:Running MediaWiki on Solaris
- on Solaris 11 / opensolarisManual:Running MediaWiki on Solaris 11 / opensolaris
- on Solaris 10Manual:Running MediaWiki on Solaris 10
on WindowsManual:Running MediaWiki on Windows
- Windows Server 2008Manual:Installing MediaWiki on Windows Server 2008
- Windows Server 2003Manual:Installing MediaWiki on Windows Server 2003
- Streamlined GuideManual:Streamlined Windows Install Guide
- Simple Windows/Apache GuideManual:Simple Windows Apache Installation
on a stickManual:Wiki on a stick
- on MoWeS PortableManual:Installing on MoWeS Portable (Windows)
- on Uniform ServerManual:Installation on Uniform Server (Windows)
- on XAMPPManual:Installing MediaWiki on XAMPP
on Sourceforge.netManual:Running MediaWiki on Sourceforge.net

Introduction[edit | edit source]

This article gives detailed instructions for people who want to run MediaWiki on a Red Hat Linux platform.

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

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

Using the Red Hat package system:

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

When using Red Hat Enterprise Linux 7 you have to use the mysql fork 'mariadb' instead of mysql - so the command would be as follows:

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

Database (MySQL) post-install configuration[edit | edit source]

Start MySQL and secure it

service mysqld start
mysql_secure_installation

For Red Hat Enterprise Linux 7

systemctl start mariadb
mysql_secure_installation

Log into MySQL monitor:

 mysql -u root -p

Create the wiki user and grant it DB creation privileges:

CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';
GRANT ALL PRIVILEGES ON *.* TO 'wiki'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

Remember the 'wiki' password for MySQL that you create here. You will need it when setting up the wiki database. You can test it with:

 mysql -u wiki -p

Next, create the database:

 CREATE DATABASE database name;

For example:

 CREATE DATABASE wikidatabase;  

To confirm that it was created:

 SHOW DATABASES;

Grant privileges to newly created DB:

 GRANT ALL PRIVILEGES ON wikidatabase.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'Pippo123456?' WITH GRANT OPTION;
 FLUSH PRIVILEGES;
 exit

To display what has been granted:

 SHOW GRANTS FOR 'wiki'@'localhost';

Autostart webserver and database daemons (services)[edit | edit source]

Make sure Apache and MySQL start on boot

chkconfig httpd on
chkconfig mysqld on

For Red Hat Enterprise Linux 7

systemctl enable mariadb
systemctl enable httpd

Download MediaWiki[edit | edit source]

Install mediawiki tarball ("sources")[edit | edit source]

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. Here I put it in /root.

cd /root
wget http://releases.wikimedia.org/mediawiki/1.25/mediawiki-1.25.2.tar.gz

Also it works with:

curl -O http://releases.wikimedia.org/mediawiki/1.25/mediawiki-1.25.2.tar.gz

(Optional, but recommended) Download the GPG signature for the tarball and verify the tarball's integrity:

curl -O http://releases.wikimedia.org/mediawiki/1.25/mediawiki-1.25.2.tar.gz.sig
gpg --verify mediawiki-1.25.2.tar.gz.sig mediawiki-1.25.2.tar.gz

Install. Use a symlink for easy upgrades.

cd /var/www
tar -zxf /root/mediawiki-1.25.2.tar.gz
ln -s mediawiki-1.25.2/ mediawiki

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

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

Webserver (Apache) post-install configuration[edit | edit source]

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.25.2). 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.25.2/ mediawiki
chown -R apache:apache /var/www/mediawiki-1.25.2 

Also it works with:

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

Restart Apache

service httpd restart

Firewall configuration[edit | edit source]

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).

Security (selinux) configuration[edit | edit source]

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 disbale selinux (not recommended), or set the correct selinux context for the MediaWiki files, running these commands as root:

 restorecon -FR /var/www/mediawiki-1.25.2/
 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 | edit source]

If you are determined to disable selinux (instead of configuring it properly as detailed above), go to /etc/selinux and modify conf making it either "permissive" or "disabled." I also had to create a link to /usr/share/mediawiki-1.25.2/load.php in my /var/www/mediawiki directory and change the ownership on the /usr/share/mediawiki-1.25.2 directory to apache.apache.

Final comments[edit | edit source]

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

References[edit | edit source]

http://www.php.net/manual/en/install.apache2.php