What Is MediaWiki?
MediaWiki is a free and open-source wiki platform developed by the Wikimedia Foundation. It powers some of the world’s largest collaborative knowledge bases, including Wikipedia.
Organizations frequently use MediaWiki to create:
- Internal documentation portals
- Knowledge bases
- Technical documentation websites
- Employee handbooks
- Community-driven content platforms
- Educational resources
Its flexibility, extensive extension ecosystem, and active development community make it a popular choice for businesses, educational institutions, and technical teams.
Why Use AlmaLinux for MediaWiki?
AlmaLinux is a stable enterprise Linux distribution designed for production environments.
Benefits of deploying MediaWiki on AlmaLinux include:
- Long-term support
- Enterprise-grade stability
- Security updates
- Compatibility with common web hosting stacks
- Strong community support
The combination of AlmaLinux, Apache, MariaDB, and PHP provides a reliable foundation for hosting MediaWiki.
WordPress Web Hosting
Starting From €2.99/Monthly
Prerequisites
Before starting the installation, ensure the following requirements are met:
Operating System
- AlmaLinux 8 or later
Access Requirements
- Root access or sudo privileges
- Internet connectivity
- A public IP address or domain name
Required Components
MediaWiki requires:
- Apache Web Server
- MariaDB Database Server
- PHP and required extensions
Step 1: Update the System
Before installing any software, update all existing packages.
sudo dnf update -y
This ensures the operating system is running the latest available packages and security updates.
Step 2: Install Apache and MariaDB
Install the web server and database server packages.
sudo dnf install httpd mariadb mariadb-server -y
Once installed, the services will be available for configuration.
Cheap VPS Server
Starting From €8/Monthly
Step 3: Install PHP 8.1 and Required Extensions
Modern MediaWiki releases work best with PHP 8.1 or newer.
Install EPEL Repository
sudo dnf install epel-release -y
Install Remi Repository
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
Update repository information:
sudo dnf update -y
Reset Existing PHP Modules
sudo dnf module reset php -y
Enable PHP 8.1 Repository
sudo dnf module enable php:remi-8.1 -y
Install PHP and Required Extensions
sudo dnf install php php-curl php-bcmath php-gd php-soap php-mbstring php-mysqlnd php-xml php-intl php-zip -y
Verify the installed PHP version:
php -v
Step 4: Start and Enable Services
Start Apache and MariaDB and configure them to launch automatically during system boot.
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
Verify service status:
sudo systemctl status httpd
sudo systemctl status mariadb
Both services should report an active running status.
Windows VPS Hosting
Remote Access & Full Admin
Step 5: Secure MariaDB
Run the built-in MariaDB security script.
sudo mysql_secure_installation
The wizard will help you:
- Set a root password
- Remove anonymous accounts
- Disable remote root login
- Remove test databases
- Improve overall database security
Follow the prompts according to your security requirements.
Step 6: Create the MediaWiki Database
Connect to MariaDB:
sudo mysql -u root -p
Create a new database:
CREATE DATABASE mediawiki_db;
Create a dedicated database user:
CREATE USER 'mediawiki_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
Grant permissions:
GRANT ALL PRIVILEGES ON mediawiki_db.* TO 'mediawiki_user'@'localhost';
Apply the changes:
FLUSH PRIVILEGES;
Exit MariaDB:
EXIT;
Record the following information because it will be required later:
- Database name
- Database username
- Database password
Step 7: Download MediaWiki
Move to a temporary directory:
cd /tmp
Download the latest MediaWiki release.
Example:
wget https://releases.wikimedia.org/mediawiki/1.40/mediawiki-1.40.1.tar.gz
The version number may change over time as new releases become available.
Step 8: Extract MediaWiki Files
Extract the archive into the web root directory:
sudo tar -xvzf mediawiki-1.40.1.tar.gz -C /var/www/html/
Create a simplified symbolic link:
sudo ln -s /var/www/html/mediawiki-1.40.1 /var/www/html/mediawiki
This allows easier future upgrades.
Step 9: Configure File Ownership
Assign the correct ownership to Apache.
sudo chown -R apache:apache /var/www/html/mediawiki
Verify ownership:
ls -la /var/www/html/
Step 10: Configure SELinux
Check the current SELinux mode:
getenforce
If SELinux is enabled, apply proper labels:
sudo restorecon -FR /var/www/html/mediawiki
This prevents permission-related issues when accessing MediaWiki through Apache.
Step 11: Configure Firewall Rules
Allow HTTP and HTTPS traffic.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
Reload the firewall:
sudo firewall-cmd --reload
Verify active rules:
sudo firewall-cmd --list-all
Step 12: Launch the Web Installer
Open a browser and visit:
http://SERVER_IP/mediawiki/
Replace:
SERVER_IP
with your actual server IP address or domain name.
The MediaWiki installation wizard will appear.
Step 13: Configure MediaWiki
The web installer will guide you through several configuration screens.
Select Languages
Choose:
- Installation language
- Wiki content language
Click Continue.
Environment Verification
MediaWiki will perform system checks to verify:
- PHP version
- Extensions
- Permissions
- Database connectivity
Resolve any warnings before continuing.
Connect to the Database
Enter:
- Database name
- Database username
- Database password
created earlier.
Continue to the next step.
Configure Database Access
Select:
Use the same account as for installation
unless you specifically require a separate database account.
Configure Wiki Information
Enter:
- Wiki name
- Administrator username
- Administrator password
- Contact information if required
Additional Options
Configure optional settings such as:
- Email support
- User permissions
- Logo customization
- Caching preferences
Continue until the installation process begins.
Step 14: Complete Installation
MediaWiki will create the required database tables and finalize the configuration.
After installation completes, a file named:
LocalSettings.php
will be generated.
Download this file and upload it to:
/var/www/html/mediawiki/
Without this file, MediaWiki cannot operate correctly.
Step 15: Access the Wiki
Visit:
http://SERVER_IP/mediawiki/
Click:
Log In
and authenticate using the administrator account created during installation.
You should now have full administrative access to your MediaWiki instance.
Managing Your MediaWiki Installation
After deployment, consider performing the following tasks:
- Configure HTTPS using SSL certificates
- Enable automatic backups
- Install useful MediaWiki extensions
- Configure caching
- Restrict registration if necessary
- Create user groups and permissions
- Monitor server resources
These improvements can enhance both security and performance.
How to Uninstall MediaWiki
If MediaWiki is no longer required, it can be removed from the server.
Stop Apache
sudo systemctl stop httpd
sudo systemctl disable httpd
Remove MediaWiki Files
sudo rm -rf /var/www/html/mediawiki
Remove any version-specific directories as needed.
Remove the Database
Connect to MariaDB:
mysql -u root -p
Delete the database:
DROP DATABASE mediawiki_db;
Delete the user account:
DROP USER 'mediawiki_user'@'localhost';
Apply changes:
FLUSH PRIVILEGES;
Exit:
EXIT;
Remove Optional Packages
If the server will no longer host MediaWiki or other websites, you may remove Apache, MariaDB, and related packages.
sudo dnf remove httpd mariadb mariadb-server
Carefully verify dependencies before removing packages on production servers.
Finalizing Your MediaWiki Deployment
MediaWiki provides a powerful platform for creating collaborative documentation systems, internal knowledge bases, and public wiki websites. When deployed on AlmaLinux with Apache, MariaDB, and PHP, it offers a stable and scalable environment suitable for both small teams and large organizations.
By following proper security practices, maintaining regular backups, and keeping both MediaWiki and the operating system updated, you can build a reliable knowledge-sharing platform that grows alongside your organization.
