How to Install MediaWiki on AlmaLinux 9
MediaWiki is the free open-source wiki software used to power Wikipedia and thousands of other wikis. The contributions of hundreds of individual developers have helped make it a feature-rich, secure and scalable platform capable of powering some of the largest collaboratively edited reference projects in the world.
Pre-requisites
- A system with AlmaLinux 9 installed and running.
- root access to the system.
Once you're all set, we'll proceed with MediaWiki installation and configuration
Update the System
dnf update -y
Install Required Packages
For MediaWiki installation we need Apache Web Server, PHP 7.4 and above, MariaDB/MySQL Database,
Use below commands to install packages,
dnf module reset php
dnf module enable php:7.4
dnf install -y httpd php php-mysqlnd php-gd php-xml php-intl mariadb-server mariadb php-mbstring php-json
Start and Enable the Apache and Database
Run the below commands to start and enable Apache and MariaDB Database services,
systemctl start httpd
systemctl enable httpd
systemctl start mariadb
systemctl enable mariadb
To make your pages available to public, you will have to edit your firewall rules to allow HTTP and HTTPS requests on your web server by using the following commands.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Output:
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@server ~]# firewall-cmd --reload
success
Configure MySQL
Create the MySQL user, database using below command,
mysql -u root -p
CREATE DATABASE mediawiki_db;
GRANT ALL PRIVILEGES ON mediawiki_db.* TO 'wiki_user'@'localhost' IDENTIFIED BY 'StrongPassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
Change StrongPassword to something more secure/unqiue when using it for your database password.
Download the MediaWiki
Check out Mediawiki's official site to download the latest version,
dnf install wget -y
wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.3.tar.gz
Extract the file using below command,
dnf install tar -y
tar -zxvf mediawiki-1.39.3.tar.gz
Move mediawiki-1.39.3 to apache document root directory /var/www/html
mv mediawiki-1.39.3 /var/www/html/mediawiki
Set the required permissions on mediawiki directory
Change the ownership and group of mediawiki directory using below command,
chown -R apache:apache /var/www/html/mediawiki/
If SELinux is enabled then apply below selinux rule on mediawiki folder,
getenforce
Output:
Enforcing
Set the rule using below command,
restorecon -FR /var/www/html/mediawiki/
Configure Apache Web Server for MediaWiki
Configure MediaWiki VirtualHost file /etc/httpd/conf.d/wiki.domainhere.info.conf
vi /etc/httpd/conf.d/wiki.domainhere.info.conf
Copy the below content and save it into the file.
Replace
wiki.domainhere.info
with your actual domain name.
<VirtualHost *:80>
ServerName wiki.domainhere.info
ServerAlias www.wiki.domainhere.info.com
ServerAdmin admin@wiki.domainhere.info.com
DocumentRoot /var/www/html/mediawiki/
<Directory /var/www/html/mediawiki>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>
Restart Apache web server using below command,
systemctl restart httpd
Configure MediaWiki
Navigate your browser to http://wiki.domainhere.info, you'll get the installation screen like below,
NOTE: Replace wiki.domainhere.info with your actual domain name
Select your language and click on continue,
Click on Continue to complete installation,
Fill the Database user, name details and click on continue,
If you want to use the same account then mark tick the box and click on continue,
Fill your wiki name , your user name, password, email address, and click on continue,
Click on Continue to install MediaWiki,
Next, MediaWiki will provide the settings that was configured so far in the form of a php
file.
The file with settings should be placed into the web root directory, /var/www/html/meddiawiki/
.
Click on the Download LocalSettings.php link, a file will be downloaded to your local system.
Open it with a notepad or similar application.
Copy the contents of the file and Switch over to the server, paste the contents into the file mentioned below:
nano /var/www/html/mediawiki/LocalSettings.php
After pasting the contents to the file, save and exit.
Restart the Apache using below command,
systemctl restart httpd
Once downloaded Click on Enter Wiki and you will get the MediaWiki Dashboard Page,
That's how we installed the MediaWiki on AlmaLinux 9 OS.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS