MediaWiki is a powerful open-source platform used for creating collaborative wikis. It’s ideal for managing large-scale documentation projects, knowledge bases, or intranet systems. This tutorial will guide you through installing and configuring MediaWiki on Rocky Linux 9 with Apache, MariaDB, PHP, and SSL.

MediaWiki Utility and Benefits

MediaWiki is highly versatile, enabling the creation of collaborative platforms for various use cases. It’s best suited for:

  • Collaborative Documentation: MediaWiki powers platforms like Wikipedia, allowing multiple users to edit, track, and maintain large-scale content projects.
  • Corporate Knowledge Management: Companies use MediaWiki to build internal knowledge hubs where employees can share and manage institutional knowledge.
  • Educational Resources: Teachers and educators use MediaWiki to manage coursework, syllabi, and research papers.
  • Community Platforms: MediaWiki’s open-source nature allows it to be customized for niche communities to share knowledge on specific subjects.

Step 1: Create an Instance on Cloud.shape.host

Step 1.1: Access the Dashboard

  1. Log in to Cloud.shape.host.
  2. Click Create, then select Instances.
Shape.host Resources dashboard with Create > Instance highlighted.

Step 1.2: Choose a Datacenter Location

Choose the most appropriate location based on your user base, like New York, London, or Frankfurt.

Shape.host instance form with the data center location selector highlighted.

Step 1.3: Select a Plan

Choose a plan that suits your MediaWiki installation, such as Standard, CPU-Optimized, or Memory-Optimized.

Step 1.4: Select an Operating System

Select Rocky Linux 9 as the operating system for MediaWiki installation.

Shape.host instance form with the operating system image selector highlighted.

Step 1.5: Configure and Launch

Set up network type and authentication method (SSH key or password), and click Create Instance.

Shape.host instance form with the Create Instance button highlighted.

Step 1.6: Locate your Instance’s IP

Shape.host Resources dashboard with the server IP address highlighted.

Step 1.7: Access the Instance

  • SSH (for Linux/macOS):
   ssh root@<your-instance-ip>

Replace <your-instance-ip> with the server’s public IP.

  • PuTTY (for Windows):
    Download PuTTY, enter the public IP, and click Open.

Step 2: Update the System

First, update your system to ensure you have the latest software versions and security patches:

dnf update
Terminal showing DNF/YUM package management commands and output.

Step 3: Install Apache, MariaDB, PHP, and Other Dependencies

Install the necessary LAMP stack (Linux, Apache, MySQL/MariaDB, PHP):

dnf install epel-release dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm
dnf module reset php
dnf module enable php:remi-8.1
dnf install httpd httpd-tools mariadb-server mariadb php php-mysqlnd php-gd php-xml php-intl php-mbstring php-json php-curl wget
Terminal showing DNF/YUM package management commands and output.
Terminal showing DNF/YUM package management commands and output.
Terminal showing DNF/YUM package management commands and output.

Step 4: Start and Enable Services

Start and enable Apache and MariaDB services:

systemctl start httpd
systemctl enable httpd
systemctl start mariadb
systemctl enable mariadb
Terminal showing systemd service management commands or output.
Terminal showing systemd service management commands or output.

Verify PHP installation:

php -v
php -m
Terminal showing php commands or output during Start and Enable Services.

Step 5: Configure Firewall

Unmask, start, and configure the firewall to allow HTTP and HTTPS traffic:

systemctl unmask firewalld
systemctl start firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent
firewall-cmd --reload
firewall-cmd --list-all
Terminal showing systemd service management commands or output.

Step 6: Secure MariaDB and Create Database

Run the following command to secure MariaDB:

mariadb-secure-installation
Terminal showing MariaDB/MySQL database security configuration prompts.
Terminal showing mariadb commands or output during Secure MariaDB and Create Database.

Log in to MariaDB and create a database for MediaWiki:

mariadb -u root -p

Then execute the following SQL queries:

CREATE DATABASE mediawikidb;
CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'p4ssw0rd';
GRANT ALL PRIVILEGES ON mediawikidb.* TO 'wikiuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'wikiuser'@'localhost';
Terminal showing SQL database and user configuration commands.

Type quit to exit from the MariaDB server.


Step 7: Download and Install MediaWiki

Navigate to the web directory and download MediaWiki:

cd /var/www/
wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.0.tar.gz
tar -zxpvf mediawiki-1.41.0.tar.gz
mv mediawiki-1.41.0 mediawiki
chown -R apache:apache /var/www/mediawiki
restorecon -FR /var/www/mediawiki/
Terminal showing file and directory setup commands.
Terminal showing file download commands and transfer output.
Terminal showing tar commands or output during Download and Install MediaWiki.
Terminal showing file and directory setup commands.
Terminal showing file ownership or permission commands.
Terminal showing MediaWiki directory ownership commands.

Step 8: Configure Apache for MediaWiki

Create an Apache configuration file for MediaWiki:

nano /etc/httpd/conf.d/mediawiki.conf

Insert the following configuration, ensuring to change ServerName to your domain:

<VirtualHost *:80>
 ServerName tutorial.shape.host
 ServerAlias tutorial.shape.host
 ServerAdmin contact@shape.host
 DocumentRoot /var/www/mediawiki

 ErrorLog /var/log/httpd/tutorial.shape.host_error.log
 CustomLog /var/log/httpd/tutorial.shape.host_access.log combined

 <Directory /var/www/mediawiki/>
 Options FollowSymlinks
 AllowOverride All
 Require all granted
 </Directory>
</VirtualHost>
Terminal showing web server configuration text.

How to Save and Quit Nano:

  • Press CTRL + O to save the file.
  • Press Enter to confirm.
  • Press CTRL + X to quit the Nano editor.

Step 9: Test Apache and Restart

Test the Apache configuration and restart the service:

apachectl configtest
systemctl restart httpd
Terminal showing an Apache configuration test.
Terminal showing systemd service management commands or output.

Step 10: Install SSL with Certbot

Install Certbot and generate SSL certificates:

dnf install certbot python3-certbot-apache

certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email contact@shape.host -d tutorial.shape.host
Terminal showing DNF/YUM package management commands and output.
Terminal showing Certbot certificate commands and messages.

Step 11: Access MediaWiki via Web Browser

Open your web browser and navigate to your domain, for example:

http://tutorial.shape.host/

You will see the MediaWiki installation page. Follow the on-screen instructions to complete the setup.

MediaWiki message that LocalSettings.php is missing, with a link to complete setup.

Select the MediaWiki default language and click Continue. The MediaWiki supports various languages as you need.

MediaWiki installer language selection.

On the environment check process, make sure that your system meets MediaWiki requirements. Then click continue again.

MediaWiki installer welcome, environment checks and license information.

Now input the database name, user, and password. Then click Continue.

MediaWiki installer database connection settings.

Tick the option to use the same account as for the installation and click Continue. With this, you will use the same database for MediaWiki users.

MediaWiki database connection settings.

Next, input your admin user, password, and email address, then click Continue. This user will be used as an admin for MediaWiki.

MediaWiki installer wiki-name and administrator account settings.

For the additional configuration, click Continue again. You can configure these later after the installation is complete.

MediaWiki installer object caching settings.

Now click Continue to confirm the MediaWiki installation.

MediaWiki installation confirmation before creating database tables.

After the installation is finished, you will an output below – Click Continue to proceed to the next section:

MediaWiki database installation progress checklist.

You will see additional instructions to complete the MediaWiki installation:

  • Download the LocalSettings.php file.
  • Place the LocalSettings.php on the DocumentRoot directory.
MediaWiki setup completion page with the LocalSettings.php download.

Step 12: Finalize Installation with LocalSettings.php

Once MediaWiki is set up through the web, create the LocalSettings.php file:

touch /var/www/mediawiki/LocalSettings.php
chown apache:apache /var/www/mediawiki/LocalSettings.php
Terminal showing touch commands or output during Finalize Installation with LocalSettings.php.
Terminal showing file ownership or permission commands.

Edit the file to add the necessary configuration downloaded during the installation process:

nano /var/www/mediawiki/LocalSettings.php

Insert the required settings, then save and exit Nano.

Move back to the MediaWiki installation page and click the link to enter your wiki. You will see the default main page of mediaWiki like the following:

MediaWiki main page after installation, with getting-started links.

You have successfully installed MediaWiki on Rocky Linux 9 with Apache, MariaDB, PHP, and SSL. This powerful wiki platform can now be accessed via your secure domain for collaborative projects and knowledge management. For high-performance hosting, consider Shape.Host’s Cloud SSD VPS to run your MediaWiki instance efficiently.