Practical Linux, Windows Server and cloud guides for IT pros.

How to Install MediaWiki on Ubuntu 22.04

Yes, you can install MediaWiki on Ubuntu 22.04, but the right version choice matters. MediaWiki’s current stable branch requires PHP 8.2 or newer, while Ubuntu 22.04 ships PHP 8.1 by default. That makes the supported long-term support branch, MediaWiki 1.43.6, the cleanest fit for a standard Ubuntu 22.04 LAMP stack.

Filed under

Published

Written by

MediaWiki logo

Yes, you can install MediaWiki on Ubuntu 22.04, but the right version choice matters. MediaWiki’s current stable branch requires PHP 8.2 or newer, while Ubuntu 22.04 ships PHP 8.1 by default. That makes the supported long-term support branch, MediaWiki 1.43.6, the cleanest fit for a standard Ubuntu 22.04 LAMP stack.

This guide focuses on a production-friendly Ubuntu 22.04 install path using Apache, MariaDB, and MediaWiki 1.43 LTS. If MediaWiki is already installed and you want to tune Apache, uploads, and hardening, use the follow-on guide: How to Configure and Harden MediaWiki on Ubuntu After Installation.

Why use MediaWiki 1.43 LTS on Ubuntu 22.04?

  • MediaWiki 1.45.1 is the current stable release, but it requires PHP 8.2 or later.
  • MediaWiki 1.43.6 is the current long-term support release and supports PHP 8.1.
  • Ubuntu 22.04 defaults to PHP 8.1, so MediaWiki 1.43.6 is the least disruptive supported option.

If you specifically want MediaWiki 1.45.x, plan on a newer PHP stack or a newer Ubuntu base image. For a straightforward Ubuntu 22.04 deployment, 1.43.6 is the safer route.

Prerequisites

  • An Ubuntu 22.04 server with sudo access
  • A DNS name or server IP you can use during setup
  • Apache, MariaDB, and PHP 8.1 packages from the Ubuntu repositories
  • Ports 80 and 443 open if the host is internet-facing

Step 1: Update Ubuntu and install the LAMP dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y apache2 mariadb-server libapache2-mod-php php php-mysql php-xml php-mbstring php-intl php-apcu php-curl php-zip imagemagick unzip

These packages cover the common MediaWiki requirements for Apache, MariaDB, and the PHP extensions typically needed for a functional install.

Step 2: Secure MariaDB and create the MediaWiki database

Run the MariaDB hardening script first, then create a dedicated database and database user for MediaWiki.

sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE mediawiki;
CREATE USER 'mediawikiuser'@'localhost' IDENTIFIED BY 'ReplaceThisWithAStrongPassword';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'mediawikiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3: Download the supported MediaWiki release

Download the MediaWiki 1.43.6 LTS tarball from the official MediaWiki release archive and extract it under /var/www.

cd /tmp
wget https://releases.wikimedia.org/mediawiki/1.43/mediawiki-1.43.6.tar.gz
sudo tar -xzf mediawiki-1.43.6.tar.gz -C /var/www/
sudo mv /var/www/mediawiki-1.43.6 /var/www/mediawiki
sudo chown -R www-data:www-data /var/www/mediawiki

Step 4: Create an Apache virtual host for MediaWiki

Create a dedicated site definition instead of editing the default Apache site directly.

sudo nano /etc/apache2/sites-available/mediawiki.conf
<VirtualHost *:80>
    ServerName wiki.example.com
    DocumentRoot /var/www/mediawiki

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

    ErrorLog ${APACHE_LOG_DIR}/mediawiki-error.log
    CustomLog ${APACHE_LOG_DIR}/mediawiki-access.log combined
</VirtualHost>

Enable the site and the rewrite module, then test Apache before restarting it.

sudo a2ensite mediawiki.conf
sudo a2enmod rewrite
sudo apache2ctl configtest
sudo systemctl reload apache2

Step 5: Complete the web installer

Open the site in your browser. If DNS is not ready yet, you can use the server IP. MediaWiki should redirect you to the installer.

http://your-server-ip/
http://wiki.example.com/

During the web-based setup:

  • Select your language
  • Choose MariaDB/MySQL as the database backend
  • Use localhost for the database host
  • Set the database name to mediawiki
  • Use the database user and password created earlier
  • Create the first MediaWiki administrator account

Step 6: Move LocalSettings.php into place

At the end of the installer, MediaWiki downloads a LocalSettings.php file. Move that file into the MediaWiki document root.

sudo mv ~/Downloads/LocalSettings.php /var/www/mediawiki/
sudo chown www-data:www-data /var/www/mediawiki/LocalSettings.php

After that file is in place, reload the site and confirm the wiki home page loads normally.

Step 7: Verify the install

Check that Apache is serving the site, the MediaWiki installer has completed, and uploads, edits, and logins work as expected.

sudo systemctl status apache2
sudo systemctl status mariadb
php -v

On Ubuntu 22.04, you should expect PHP 8.1 unless you have deliberately upgraded the PHP runtime.

What to do after installation

A working install is only the start. The next jobs are:

  • Enable HTTPS with Let’s Encrypt or your preferred certificate workflow
  • Set up clean URLs if you want friendlier page addresses
  • Review file upload settings and permissions
  • Back up both the database and the images/ directory
  • Harden the Apache configuration and restrict access where needed

That work now lives in the companion page: How to Configure and Harden MediaWiki on Ubuntu After Installation.

Related TurboGeek guides

Elsewhere On TurboGeek:  How to Create a Custom Linux MOTD: Step-by-Step Guide

Find more on the site

Keep reading by topic.

If this post was useful, the fastest way to keep going is to pick the topic you work in most often.

Want another useful post?

Browse the latest posts, or support TurboGeek if the site saves you time regularly.

Translate »