How to install Mediawiki in Centos 7

To install Mediawiki in Centos 7

In this article we will learn how to install Mediawiki. Mediawiki is an opensource wiki application which is written in PHP programing. The contents of Media wiki are stored in database. It is used for several wiki projects like Wikipedia, Wikimedia and many more.


To install Mediawiki

Before installing Mediawiki, check whether the following services are active.

Apache service

 [root@linuxhelp ~]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service  enabled  vendor preset: disabled)
   Active: active (running) since Sun 2016-07-10 23:30:51 IST  1h 37min ago
.
.
.
Jul 10 23:30:51 linuxhelp.com systemd[1]: Started The Apache HTTP Server.

Mariadb service

[root@linuxhelp Desktop]# systemctl status mariadb.service
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service  enabled  vendor preset: disabled)
   Active: active (running) since Sun 2016-07-10 23:30:51 IST  1h 39min ago
.
.
.
Jul 10 23:30:51 linuxhelp.com systemd[1]: Started MariaDB database server.

If both the services are not active, activate it and proceed.

Open the mysql shell, create the database for Mediawiki content and grant permission for the database.

[root@linuxhelp ~]# mysql &ndash u root -p

Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 2
Server version: 5.5.47-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.
MariaDB [(none)]>  create database media_db 
Query OK, 1 row affected (0.35 sec)
MariaDB [(none)]>  grant all privileges on media_db.* TO ' linux_user' @' localhost'  identified by ' p@ssw0rd'  with grant option 
Query OK, 0 rows affected (0.19 sec)
MariaDB [(none)]>  flush privileges 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>  q 
Bye

Download the Media-wiki package by using the following command.

[root@linuxhelp ~]# wget https://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.2.tar.gz
--2016-07-07 17:54:44--  https://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.2.tar.gz
Resolving releases.wikimedia.org (releases.wikimedia.org)... 208.80.154.251, 2620:0:861:ed1a::3:d
.
.
.
Saving to: ‘ mediawiki-1.24.2.tar.gz’ 
100%[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=====> ] 21,874,196  49.9KB/s   in 45s   
2016-07-07 18:09:15 (23.6 KB/s) - ‘ mediawiki-1.24.2.tar.gz’  saved [21874196/21874196]

Extract the package by using the " tar" command.

[root@linuxhelp ~]# tar -xvf 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/languages/.htaccess
mediawiki-1.24.2/languages/ConverterRule.php
mediawiki-1.24.2/languages/Language.php

Create a directory inside the web root directory and move the extracted file.

[root@linuxhelp ~]# mv mediawiki-1.24.2 /var/www/html/media

Change the ownership and give the required permission for that media directory.

[root@linuxhelp ~]#  chown -R apache:apache /var/www/html/media/
[root@linuxhelp ~]# chmod 755 /var/www/html/media/

Allow the firewall to access the Media-wiki.

[root@linuxhelp ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@linuxhelp ~]# firewall-cmd --reload
Success

Check the port using iptables command.

[root@linuxhelp ~]# iptables-save | grep 80
-A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT

Check the selinux status in webroot directory.

[root@linuxhelp Desktop]# getenforce
Enforcing
[root@linuxhelp Desktop]# restorecon -r /var/www/html/media/

Open the web-browser and navigate to http://< IP_address> /media/

Click " Set up the wiki" to configure.

Choose the preferred language and click continue.

Welcome screen of Mediawiki appears. Click continue to proceed further.

Now connect Mediawiki to the database.

Enter the following fields and click Continue.

Select the database settings as required.

Fill the Installation fields

Now click continue to install.

We have successfully installed Mediawiki and it automatically generates LocalSetting.php file. click to download it

This file contains all the configurations needed to run the Media-wiki.

Comment
parthiban
Aug 27 2018
Please check your apache's log file for a detailed error report, I think you got some misconfiguration on your apache so it may deny the /media directory
la558
Aug 03 2018
Hello, This is a great tutorial. Thank you. I'm getting a problem when accessing the url through the browser; FYI - I'm installing the mediawiki in a Linux virtualbox - CentOS 7 if i type in the url browser > /media/ i get > Not Found the requested URL /media/ was not found on this server === I know the /media/directory exists and has media wiki files and folders, because I can navigate to it through the terminal and see all its content.
Add a comment
FAQ
Q
Does MediaWiki work with safe_mode enabled?
A
Yes, MediaWiki is a safemode but only to a limited degree in safemode
Q
How do I stop anonymous users from editing any page?
A
To stop the annonymous user is by changing the value of the $wgGroupPermissions configuration option. Edit LocalSettings.php and add the line:
"$wgGroupPermissions['*']['edit'] = false;"
Q
How do I restrict account creation?
A
By using this command you can restrict the user
'$wgGroupPermissions['*']['createaccount'] = false;"
Q
How do I completely disable caching in MediaWiki?
A
To disable caching in MediaWiki
Add in your LocalSettings.php file the following lines:

$wgEnableParserCache = false;
$wgCachePages = false;
Q
How do I allow uploading of additional formats?
A
By using this command you allow the additional formats
Syntax: "$wgFileExtensions[] = 'pdf';"