How to install MediaWiki on Ubuntu 22.04 LTS Jammy

Let’s learn the steps to install MediaWiki on Ubuntu 22.04 LTS Jammy JellyFish server to run your own Wiki system such as Wikipedia.

Mediawiki is an open-source management software for content in the form of a wiki system that makes websites such as possible. With the help of MediaWiki, you can not only read a website together with other users but also edit it in real-time. You can quickly and easily put texts, photos, and movies on your Mediawiki page.

With the help of MediaWiki, you can quickly edit, delete or publish the content of your website. Mediawiki keeps every currently saved change without deleting the previous versions. If you accidentally deleted important content, you can restore it at any time. It enables joint editing of content and is suitable, among other things, for building knowledge databases or log collections.

In contrast to the other content management systems, MediaWiki offers few design options for the layout and design of the websites. The primary function, on the other hand, is an editing mode for each wiki page, which also allows a newcomer to change the text and content of the page without much training.


Steps to install MediaWiki on Ubuntu 22.04 LTS Server

The steps given here can also be used for the other versions of Ubuntu server or desktop such as 20.04/18.04 including other similar systems.

1. Update Ubuntu 22.04 LTS

First of all, run the system update and upgrade command to make sure your system packages and APT index repository cache are in their latest state.

sudo apt update && sudo apt upgrade


2. Install Apache

We need an Apache web server, PHP, and MySQL stack on our system to install MediaWiki on Ubuntu 22.04 server. However, instead of MySQL, here we are using its fork MariaDB.

sudo apt install apache2

To make sure the webserver service is enabled in the background.

sudo systemctl enable --now apache2

To check status:

systemctl status apache2 --no-page -l

command to check apache2 service


3. Install PHP and required extensions 

To have the latest version of PHP, add the Ondrej repository:

sudo add-apt-repository ppa:ondrej/php

Run system update command:

sudo apt update

Use APT to get PHP

For the latest version 8.x

sudo apt install imagemagick php php-{fpm,intl,xml,curl,gd,mbstring,mysql,apcu,zip}

For those who want to use php7.4 then here is the command:

sudo apt install imagemagick php7.4 php7.4-{fpm,intl,xml,curl,gd,mbstring,mysql,apcu,zip}


Configure php.ini

Note: if you have multiple versions of PHP then replace the * with the version in the following lines which you want to use for Mediawiki and set as default on your system.

sudo nano /etc/php/*/fpm/php.ini

Find and Change the values of the following lines as shown below:

file_uploads = On
allow_url_fopen = On
upload_max_filesize = 64M
memory_limit = 256M
max_execution_time = 600
date.timezone = America/Chicago

Once you are done with editing, save the file using Ctlr+O, hit Enter button, and then exit the file editor- Ctlr+X.

Now, restart PHP-FPM:

sudo systemctl restart php*-fpm.service


4. Install MariaDB and Create a New Database

Although you can use MySQL or PostgreSQL, here we are using the MariaDB fork of MySQL to establish a Database server for MediaWiki. Follow the given commands to set up MariaDB and create Database for this open-source Wiki platform.

sudo apt install mariadb-server

Once the installation is completed, secure your Database by setting up a root password and removing unnecessary access.

sudo mysql_secure_installation

The given questions will ask by the system, the example of answers is also given below:

Enter current password for root (enter for none): Press ENTER
Set root password? [Y/n]: Y
New password: Set-your-new-password
Re-enter new password: Set-your-new-password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once the process of securing the Database server is done, let’s enable and start its service:

sudo systemctl enable --now mariadb

To check the status:

sudo systemctl status mariadb --no-pager


5. Create Database for MediaWiki

sudo mysql
CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost' WITH GRANT OPTION;
flush privileges;

Note: Replace wikidb with the Database name you want to give, similarly wikiuser with username and strongpassword with the password that you want to set.


6. Download MediaWiki file

MediaWiki installation files are not available to download and set up directly using the APT package manager. To get that, we manually need to download it from the official website of MediaWiki, follow the page link to visit.

There right-click on the .Tar.GZ link and Copy Link Address.

Download MediaWiki file

Get back to your command terminal from where you are accessing the Ubuntu 22.04 Server and use the wget command to download the MediaWiki files.

cd /tmp


wget -O mediawiki.tar.gz paste-copied-link

Example :

wget -O mediawiki.tar.gz

Extract the file, once downloaded:

sudo tar -zxvf mediawiki.tar.gz

Create a directory for MediaWiki in Webroot

sudo mkdir -p /var/www/html/wiki

Move extracted folder files into it:

sudo mv mediawiki*/* /var/www/html/wiki

Change the owner of the MediaWiki directory to the ‘www-data’ user and group:

sudo chown -R www-data:www-data /var/www/html/wiki


7. Install MediaWiki on Ubuntu 22.04 LTS

After completing the all above given steps, let’s start the web installation of MediaWiki to finalize the process of setting up MediaWiki on the Ubuntu server.

For that, open your local browser and point it to the domain or IP address of the Ubuntu server where you are installing MediaWiki in the following way:


If everything goes well, you will have the initial window to initiate the process of setting up the wiki. Click on the “Set up the wiki” link.

Setup Wiki first Linux

Select the language in which want to install the MediaWiki, if it is apart from English otherwise simply click on the “Continue” button.

Select MediaWiki language


Click the Continue button to accept the Terms.

Accept terms and conditions

Add Database Details:

We have created a database to use with MediaWiki in this tutorial, so add the details of that such as the Database name, username, and password you have.


Add Database Details in MediaWiki

If the supplied database details are correct, you will have the Database Settings page, let the selected items on this page as it is, and move forward using the Continue button.

Wiki Database account for Web access

Select the User rights for a profile as per your requirements.

Create User account on MediaWiki

If all the requirements needed by the MediaWiki are satisfied, click on the “Continue” button.

Install MediaWiki Ubuntu 22.04 Linux

Soon the installation will be completed and the system will generate a “LocalSettings.php” that contains all the configuration you have done. Make sure you have downloaded it on your system and after that upload it to the MediaWiki root directory we have created i.e /var/www/html/wiki/.

You can use some FTP client or file manager if you are using some hosting service.

After downloading and moving the file to the Wiki root folder give its rights to the Apache user:

chown www-data:www-data /var/www/html/wiki/LocalSettings.php

Download LocalSettings PHP file

Finally, click on the Enter your Wiki link to get access to the MediaWiki main page installed and running on Ubuntu 22.04 LTS Jammy.

MediaWiki installation on Ubuntu 22.04 Jammy


For more information about this topic and to understand the MediaWiki functionally in detail check the Official Documentation. 


Other Articles:

NGINX vs. Apache: Comparision of web servers to host your website
How to Install Vaultwarden on Ubuntu 22.04 LTS Jammy
How to reset root password in Debian 11 Bullseye




5 thoughts on “How to install MediaWiki on Ubuntu 22.04 LTS Jammy”

  1. Everything went well right up the point where instructions say if everything goes well. Connecting to the server with local browser displays a nice page telling me something is wrong. No mention of what to do in this fine set of instructions

  2. Step #5 is not CLI and no indication of what shell/app should be running for these commands to work. All progress stopped here. What should context be for Step #5 to proceed?

  3. I made the necessary configurations on Ubuntu. However, I encountered this error: (98) Address already in use: AH00072: make_sock: could not bind to address Then, I changed the Apache port to 86 and 1443, and Apache started working. But http://server-ip/wiki This site can’t be reached. How can I fix this? Please help.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.