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
- Log in to Cloud.shape.host.
- Click Create, then select Instances.
Step 1.2: Choose a Datacenter Location
Choose the most appropriate location based on your user base, like New York, London, or Frankfurt.
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.
Step 1.5: Configure and Launch
Set up network type and authentication method (SSH key or password), and click Create Instance.
Step 1.6: Locate your Instance’s IP
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
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
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
Verify PHP installation:
php -v
php -m
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
Step 6: Secure MariaDB and Create Database
Run the following command to secure MariaDB:
mariadb-secure-installation
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';
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/
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>
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
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
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.
Select the MediaWiki default language and click Continue. The MediaWiki supports various languages as you need.
On the environment check process, make sure that your system meets MediaWiki requirements. Then click continue again.
Now input the database name, user, and password. Then click Continue.
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.
Next, input your admin user, password, and email address, then click Continue. This user will be used as an admin for MediaWiki.
For the additional configuration, click Continue again. You can configure these later after the installation is complete.
Now click Continue to confirm the MediaWiki installation.
After the installation is finished, you will an output below – Click Continue to proceed to the next section:
You will see additional instructions to complete the MediaWiki installation:
- Download the LocalSettings.php file.
- Place the LocalSettings.php on the DocumentRoot directory.
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
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:
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.