In this tutorial, we will show you how to install MediaWiki on Ubuntu 22.04 LTS. MediaWiki, the engine behind the renowned Wikipedia, is a free and open-source software that allows you to create and manage your own wiki site. It‘s a powerful tool for collaborative knowledge sharing, enabling users to create, edit, and link web pages effortlessly. In the digital age, where information is the most valuable asset, having a platform like MediaWiki can be a game-changer for businesses, educational institutions, and communities alike.
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 Ubuntu 22.04. You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- Access the terminal on your Ubuntu system, where we’ll execute the commands for a seamless Roundcube installation.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for MediaWiki.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install MediaWiki on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First and foremost, ensure your Ubuntu system is up-to-date by running the following commands:
sudo apt update sudo apt upgrade
Step 2. Installing LAMP Stack.
The LAMP stack, consisting of Apache, MySQL, and PHP, provides a robust foundation for Roundcube. If you do not have LAMP installed, you can follow our guide here.
Step 3. Installing MediaWiki on Ubuntu 22.04.
MediaWiki doesn‘t come in the standard Ubuntu repositories, so you’ll need to download it manually from the official website. Use the
wget command to download the latest version:
Once downloaded, extract the tar.gz file using the
tar xvzf mediawiki-*.tar.gz
Next, create a directory in the webroot (usually
/var/www/html) and move the extracted files into it:
sudo mkdir /var/www/html/mediawiki sudo mv mediawiki-1.37.1/* /var/www/html/mediawiki
For security reasons, change the owner of the MediaWiki directory to the ‘www-data’ user and group, which is the Apache web server user in Ubuntu:
sudo chown -R www-data:www-data /var/www/html/mediawiki
Step 4. Configuring MySQL for MediaWiki.
Before proceeding with the MediaWiki installation, you need to create a new MySQL database and user. Access the MySQL shell with the following command:
sudo mysql -u root -p
In the MySQL shell, execute the following commands:
CREATE DATABASE mediawiki; CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Now, navigate to the MediaWiki directory and run the installation script:
cd /var/www/html/mediawiki sudo php maintenance/install.php
Follow the instructions in the script, providing the necessary information such as the name of your wiki, admin username and password, and the details of the MySQL database you created earlier.
Step 5. Accessing MediaWiki Web Interface.
After running the installation script, open your web browser and navigate to your domain name or IP address followed by ‘
/mediawiki‘. This will start the MediaWiki installation wizard, which will guide you through the rest of the setup process.
Step 6. Enabling HTTPS for MediaWiki.
Securing your MediaWiki installation with HTTPS is crucial to safeguard data transmission. In this guide, we’ll use Certbot, a tool from Let’s Encrypt, to obtain and install a free SSL certificate, ensuring a secure communication channel. Begin by installing Certbot and the Apache plugin:
sudo apt install certbot python3-certbot-apache
Run Certbot to obtain a certificate and automatically configure Apache:
sudo certbot --apache
Step 7. Configure Firewall.
Before proceeding, ensure you have administrative privileges and UFW installed. If not, install UFW using:
sudo apt install ufw
Allow traffic on the Apache web server port (default is 80 for HTTP and 443 for HTTPS):
sudo ufw allow 'Apache Full'
Now, enable UFW:
sudo ufw enable
Congratulations! You have successfully installed MediaWiki. Thanks for using this tutorial for installing the MediaWiki on the Ubuntu system. For additional help or useful information, we recommend you check the official MediaWiki website.