How To Install MediaWiki on Debian 12
In this tutorial, we will show you how to install MediaWiki on Debian 12. MediaWiki is a powerful, open-source wiki software that powers some of the most visited sites on the internet, including Wikipedia. It’s a robust platform for collaborative writing, knowledge sharing, and information storage.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the MediaWiki on a Debian 12 (Bookworm).
Prerequisites
- A server running one of the following operating systems: Debian 12 (Bookworm).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- You will need an active internet connection to download the MediaWiki package.
- A domain name pointed to your server IP (optional but recommended for a production environment).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install MediaWiki on Debian 12 Bookworm
Step 1. Before installing any new software, it’s crucial to ensure that your Debian 12 system is up to date. This can be achieved by running the following commands in the terminal:
sudo apt update sudo apt upgrade
This command first updates the list of available packages and their versions then upgrades the installed packages to their latest versions.
Step 2. Installing LAMP Stack.
Before starting this tutorial, the LAMP server must be installed on your server. If you do not have LAMP Stack installed, you can follow our guide here.
Step 3. Installing MediaWiki on Debian 12.
Fetch the latest stable release of MediaWiki from the official website using wget
:
wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.0.tar.gz
Once downloaded, extract the MediaWiki archive to your web directory:
tar -xvzf mediawiki-*.tar.gz sudo mv mediawiki-1.41.0 /var/www/html/mediawiki
Step 4. Configure MySQL for MediaWiki.
MediaWiki uses a database to store all its data. Therefore, you need to create a new MySQL database and user for MediaWiki. Here‘s how:
Log in to MySQL:
sudo mysql -u root -p
CREATE DATABASE mediawikidb; GRANT ALL PRIVILEGES ON mediawikidb.* TO 'mediawikiuser'@'localhost' IDENTIFIED BY 'your-strong-password'; FLUSH PRIVILEGES; EXIT;
Step 5. Configure Apache for MediaWiki.
Next, you need to configure Apache to serve your MediaWiki site. This involves creating a new Apache configuration file and enabling the rewrite module. Create a new Apache configuration file:
sudo nano /etc/apache2/sites-available/mediawiki.conf
Add the following configuration to the file:
<VirtualHost *:80> ServerName your-domain.com DocumentRoot /var/www/html/mediawiki <Directory /var/www/html/mediawiki/> Options FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Enable the new configuration and the rewrite module:
sudo a2ensite mediawiki sudo a2enmod rewrite
Restart Apache to apply the changes:
sudo systemctl restart apache2
Step 6. Securing MediaWiki with SSL.
First, you need to install Certbot, which is a client package that manages Let’s Encrypt SSL. You can install it using the following command:
sudo apt-get install python3-certbot-apache
Next, you can use Certbot to obtain and install an SSL certificate for your domain. Replace your-domain.com
with your actual domain:
sudo certbot --apache -d your-domain.com
During the installation process, Certbot will prompt you for some basic information including your email address and domain name. Follow the prompts to complete the installation.
Step 7. Configure Firewall.
First, you need to install UFW, which is a user-friendly front-end for managing a Linux firewall. You can install it using the following command:
sudo apt update sudo apt upgrade sudo apt install ufw
Now we set up an Uncomplicated Firewall (UFW) with Apache to allow public access on default web ports for HTTP and HTTPS:
sudo ufw allow 'Apache Full' sudo ufw allow 'Apache Secure'
Step 8. Accessing MediaWiki Web UI.
Now, you can finalize the MediaWiki installation by navigating to https://your-domain.com
in your web browser. This will open the MediaWiki setup wizard, where you can enter the database details and configure other settings.
Congratulations! You have successfully installed MediaWiki. Thanks for using this tutorial to install the latest version of the MediaWiki on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official MediaWiki website.