How to Install MediaWiki on Ubuntu 22.04

MediaWiki is the free open-source wiki software used to power Wikipedia and thousands of other wikis. The contributions of hundreds of individual developers have helped make it a feature-rich, secure and scalable platform capable of powering some of the largest collaboratively edited reference projects in the world.

Update the System

apt update -y

apt upgrade -y 

Install LAMP Stack

Install Linux(Apache, PHP, and MySQL) on system using below command,

apt-get install apache2 mariadb-server php php-mysql libapache2-mod-php php-xml php-mbstring php-intl

Once the installation is complete, enable Apache, (to start automatically upon system boot), start the webserver, and verify the status using the commands below.

systemctl enable apache2

systemctl start apache2 

systemctl status apache2


root@vps:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-04-04 20:07:01 UTC; 22h ago
   Main PID: 26933 (apache2)
      Tasks: 11 (limit: 3543)
     Memory: 67.1M
        CPU: 9.197s
     CGroup: /system.slice/apache2.service
             ├─26933 /usr/sbin/apache2 -k start
             ├─26934 /usr/sbin/apache2 -k start

also, Enable the MariaDB server using below command,

systemctl enable mariadb

systemctl start mariadb

systemctl status mariadb


root@vps:~# systemctl status mariadb
● mariadb.service - MariaDB 10.5.18 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-04-04 19:43:11 UTC; 22h ago
       Docs: man:mariadbd(8)
   Main PID: 23679 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 8 (limit: 3543)
     Memory: 104.5M
        CPU: 22.999s
     CGroup: /system.slice/mariadb.service
             └─23679 /usr/sbin/mariadbd

Download the MediaWiki

Check out MediaWiki's Official Site to download the latest version,

cd /tmp/


Extract the file in your Web Directory,

tar -xvzf /tmp/mediawiki-*.tar.gz

mkdir /var/lib/mediawiki

mv mediawiki-*/* /var/lib/mediawiki

Configuring Apache vHost

Now, create a new Apache configuration file for MediaWiki with the following command.

Replace with the domain name of your own for all the below code examples:

vi /etc/apache2/sites-available/

Now, press i to go to INSERT mode and add the following configuration in the file.

<VirtualHost *:80>

    DocumentRoot /var/www/html/mediawiki

    ErrorLog ${APACHE_LOG_DIR}/wiki.domainhere.info_error.log
    CustomLog ${APACHE_LOG_DIR}/wiki.domainhere.info_access.log combined

    <Directory /var/www/html/mediawiki/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted


Enable SSL and Rewrite:

a2enmod rewrite


a2enmod rewrite ssl

Restart Apache:

systemctl restart apache2

Enable http and https ( 80/443 )

To enable http and https connection through the firewall, follow the commands:

ufw allow 80/tcp

ufw allow 443/tcp    

Configure MySQL

Create the MySQL user, database using below command,

mysql -u root -p 


CREATE USER 'mysql_user'@'localhost' IDENTIFIED BY 'Strong_Password';

GRANT ALL ON my_wiki.* TO 'mysql_user'@'localhost';



Replace Strong_Password with an actual password.

Configure PHP

Edit the PHP configuration file, php.ini. It is located at /etc/php/7.*/apache2/php.ini, depending on exact version of PHP,

Change the Maximum Upload File Size to 20 M

upload_max_filesize = 20M

To run the PHP script without errors chagne the Memory Limit to 128M,

memory_limit = 128M

If it is already set to 128M or more, Save the file and exit.

Configure MediaWiki

Navigate your browser to http://localhost/mediawiki using below command,

ln -s /var/lib/mediawiki /var/www/html/mediawiki

It will give you the issue like mbstring and xml are missing even you have to installed them, activate them using below command,

phpenmod mbstring

phpenmod xml

Restart the Apache Service using below command,

systemctl restart apache2.service

Navigate your browser to, you'll get the installation screen like below,

Replace with your actual domain name


Select your language and click on continue,


Click on Continue to complete installation,


Fill the Database user, name details and click on continue,


If you want to use the same account then mark tick the box and click on continue,


Fill your wiki name , your user name, password, email address, and click on continue,


Click on Continue to install MediaWiki,



Next, MediaWiki will provide the settings that was configured so far in the form of a php file. The file with settings should be placed into the web root directory, /var/www/html/meddiawiki/.
Click on the Download LocalSettings.php link, a file will be downloaded to your local system.

Open it with a notepad or similar application.

Copy the contents of the file and Switch over to the server, paste the contents into the file mentioned below:

nano /var/www/html/mediawiki/LocalSettings.php

After pasting the contents to the file, save and exit.


Restart the Apache using below command,

Once downloaded Click on Enter Wiki and you will get the MediaWiki Dashboard Page,


That's how we installed the MediaWiki on Ubuntu 22.04 OS.