Introduction
MediaWiki is a free and open-source application that allows anyone to create a wiki website on a self-hosted server. These kinds of websites are beneficial in contexts where several people need to create and modify pages in a quick and easy way.
Note: The installation guide of this article supports CentOS 7 and CentOS 8.
Prerequisites
- A root or non-root user with
sudo
privileges.
Install LAMP Server:
Note: First two steps are not required for CentOS 8.
- You need to enable the EPEL and Remi repositories to install the latest PHP version.
# sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# sudo yum install epel-release -y -
Next, we are going to enable php7.3 from the Remi repository.
# sudo yum-config-manager --enable remi-php73
-
Before installing MediaWiki First, need to install Apache, MariaDB, PHP, and other PHP extensions on the server and run the below command to install all the LAMP components.
# sudo yum install -y httpd mariadb mariadb-server php php-mysqlnd php-gd php-xml php-intl php-mbstring php-json
Create a Database:
- Start and enable the MariaDB services before creating the database.
# sudo systemctl start mariadb
# sudo systemctl enable mariadb.service - Login to the MariaDB shell.
# mysql
- Create a MediaWiki database.
CREATE DATABASE mediawiki;
- Create a user for MediaWiki and give the privileges to the user on the MediaWiki database.
CREATE USER 'wikiuser'@'localhost' identified by 'password';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password'; -
Flush the privileges and exit from the MariaDB.
flush privileges; exit;
Download and install MediaWiki:
- Install wget package.
# sudo yum install wget -y
-
Download the latest version of MediaWiki to the Apache web root directory.
# wget https://releases.wikimedia.org/mediawiki/1.32/mediawiki-1.32.0.tar.gz --no-check-certificate
-
Once the download is completed, unzip the downloaded file with the following command.
# sudo tar -zxvf mediawiki-1.32.0.tar.gz
-
Move the extracted directory to the Apache web root directory.
# mv mediawiki-1.32.0 /var/www/html/mediawiki
-
Set proper permission to the MediaWiki with the following command.
# sudo chown -R apache:apache /var/www/html/mediawiki/
-
If SELinux is enabled on your system then apply the below SELinux rule on the MediaWiki directory.
# getenforce
# sudo restorecon -FR /var/www/html/mediawiki/ - Enable and restart the Apache service.
# systemctl enable httpd
# systemctl restart httpd - Open your web browser and access the MediaWiki installation page using http://ip_address/mediawiki/. Click on the set_up_the_wiki link as shown below image to set up MediaWiki.