UbuntuUbuntu Based

How To Install MediaWiki on Ubuntu 22.04 LTS

Install MediaWiki on Ubuntu 22.04

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.
  • A non-root sudo user or 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 MediaWiki. 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:

wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.0.tar.gz

Once downloaded, extract the tar.gz file using the tar command:

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 USER 'wikiuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost';

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.

Install MediaWiki on Ubuntu 22.04 LTS Jammy Jellyfish

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.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button