How to Install MediaWiki on CentOS 7

Install the prerequisite OS packages using yum command

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

output:

[[email protected] ~]# yum install httpd php php-mysql php-gd mariadb-server php-xml php-intl mysql
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/4): base/7/x86_64/group_gz                              | 166 kB   00:00     
(2/4): extras/7/x86_64/primary_db                          | 156 kB   00:00     
(3/4): updates/7/x86_64/primary_db                         | 1.3 MB   00:00     

Start the Web Server and Database Service

systemctl restart httpd.service ; systemctl enable httpd.service

output:

[[email protected] ~]# systemctl restart httpd.service ; systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

systemctl restart mariadb.service ; systemctl enable mariadb.service

output:

[[email protected] ~]# systemctl start mariadb.service ;systemctl enable mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Create Mediawiki Database

mysql -u root -p

output:

[[email protected] ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server

CREATE DATABASE mediawiki_db;

output:

MariaDB [(none)]> CREATE DATABASE mediawiki_db;
Query OK, 1 row affected (0.00 sec)

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

output:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON mediawiki_db.* TO 'wiki_user'@'localhost' IDENTIFIED BY '[email protected]@123#' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

FLUSH PRIVILEGES;

output:

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Download MediaWiki 1.24.2 with wget command

wget https://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.2.tar.gz

output:

[[email protected] ~]# wget https://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.2.tar.gz
--2019-01-12 09:05:48--  https://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.2.tar.gz
Resolving releases.wikimedia.org (releases.wikimedia.org)... 91.198.174.192, 2620:0:862:ed1a::1
Connecting to releases.wikimedia.org (releases.wikimedia.org)|91.198.174.192|:443... connected.

Untar the downloaded file using below tar command.

tar -zxpvf mediawiki-1.24.2.tar.gz

output:

[[email protected] ~]# tar -zxpvf mediawiki-1.24.2.tar.gz
mediawiki-1.24.2/
mediawiki-1.24.2/opensearch_desc.php5
mediawiki-1.24.2/index.php5
mediawiki-1.24.2/extensions/

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

mv mediawiki-1.24.2 /var/www/html/mediawiki

output:

[[email protected] ~]# mv mediawiki-1.24.2 /var/www/html/mediawiki
You have mail in /var/spool/mail/root

Set the required permissions on mediawiki directory

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

output:

[[email protected] html]# chown -R apache:apache /var/www/html/mediawiki/

chmod 755 /var/www/html/mediawiki/

output:

[[email protected] html]# chmod 755 /var/www/html/mediawiki/

output:

[[email protected] html]# chmod 755 /var/www/html/mediawiki/

Now start the MediaWiki web based installation

firewall-cmd --zone=public --add-port=80/tcp --permanent

output:

[[email protected] html]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success

firewall-cmd --reload

output:

[[email protected] html]# firewall-cmd --reload
success

iptables-save | grep 80

output:

-A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT

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

restorecon -FR /var/www/html/mediawiki/

output:

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

Restart apache service.

systemctl restart httpd.service 

output:

[[email protected] html]# systemctl restart httpd.service 

Now Open the web browser type http:///mediawiki

http://185.243.115.75/mediawiki