MediaWiki - Applying Major Revision Updates

Below is the process that I have been using to apply the latest major release update for MediaWiki. I hope you find it useful, please send me any questions or comments, I read them all and will respond.

Please note: This procedure has been tested with upgrading from 1.35.x to 1.36. Version 1.35 introduced VisualEditor extension being built in and as a result, upgrading earlier versions using this method may break your installation. This process is functionally identical to applying minor revision updates (MediaWiki - Applying Minor Revision Updates).

My MediaWiki Server Environment

  • Debian 10
  • Apache2 ( latest version)
  • MariaDB or My SQL (latest version)
  • PHP 7.4.20 (NOTE The MediaWiki foundation states there are issues using PHP v7.4.2 but seems the warning is outdated as other build documents reference PHP v7.4. It seems the information needs to be updated. I have had no issues running MediaWiki 1.36 with PHP v 7.4.20)
  • PHP v8.0 Note - Current MediaWiki documentation states that MediaWiki is not yet fully compatible with PHP v8.0.x yet.

Layout of my MediaWiki install

  • My MediaWiki server is on a dedicated VM instance and there are no other websites or services installed
  • The MediaWiki (live) website is installed at - /var/www/html/
  • For updates and upgrades, I use a dedicated working directory at /var/www/mw
  • I do this to keep things organized and tidy
  • After the upgrade or update, I keep the archive in the /mw directory for reference to know exactly what version is currently installed without needing to go thru the website
  • After upgrade, I do remove previous update/upgrade version archives in the /mw directory
  • I don’t use root user so all the commands will use SUDO. If you run as root, modify commands accordingly

Best Practice Recommendations Before Upgrading

  • Update the system (sudo apt update && sudo apt upgrade)
  • If the system has been up for a long time, reboot the system before upgrading
  • Backup the system
  • If this is a VM, snapshot creation before updating is sufficient. If something goes wrong, you can roll back
  • If this is a bare metal installation, recommend backup of the database as it contains all the info from your MediaWiki site

Optional - Verify the current version of MediaWiki from within your MediaWiki website instance

  • Log into your MediaWiki website with an admin user and navigate to Special pages → Version (under data and tools section) - At the top under installed software section you should see MediaWiki and the new version next to it.

TL;DR Update Commands
Source - Manual:Upgrading - MediaWiki
sudo systemctl stop apache2
sudo cp /var/www/html/LocalSettings.php /var/www/html/LocalSettings.php.bak
cd /var/www/mw
sudo wget
sudo tar xvzf mediawiki-1.36.0.tar.gz -C /var/www/html/ --strip-components=1
cd /var/www/html/maintenance
sudo ./update.php
sudo systemctl start apache2
sudo rm mediawiki-1.35.2.tar.gz

Long Form Update Process with Step-by-Step and Explanations

1. Update Process

  • From the terminal, navigate to the /mw working directory
  • If you don’t have this, it can be created with the command
    sudo mkdir /var/www/mw
  • To navigate into the working directory using
    cd /var/www/mw
  • In the /mw working directory, list out the current contents with
    ls -la

2. Stopping the Apache web service

  • Make sure all users are off of your MediaWiki site
  • Stop the Apache2 service with
    sudo systemctl stop apache2
  • (Optional) If you want to see the status of the Apache service, use
    sudo systemctl status apache2 (it should say stopped)
    Ctrl + C to exit

3. Make a copy of the LocalSettings.php file

  • The LocalSettings.php file is a critical file containing the configuration for your entire MediaWiki website
  • Getting a quick copy of the LocalSettings.php file is strongly recomended
  • To make a copy of the file, use the cp command. My MediaWiki install is located in /var/www/html so the LocalSettings.php file is in there
  • To make a copy, use
    sudo cp /var/www/html/LocalSettings.php /var/www/html/LocalSettings.php.bak
  • A copy of the LocalSettings.php file has been created and has the .bak for the file extension. If you want to verify it use the
    ls -la /var/www/html command to see that it is present

4. Download the MediaWiki update

  • Should be in the /mw working directory, if you need to check either look at path in the terminal or use the pwd command.
  • To download the update, we will use wget to pull it from MediaWiki repository
  • (Optional) If wget is not installed use the following command to install it and the https transport for apt. The install command is
    sudo apt install wget apt-transport-https
  • Downloading the current version of MediaWiki is info is here at
  • As of this writing, version 1.36.0 is what we will be updating, so to get it we use the command
    sudo wget
  • When completed the archive will be in the /mw working directory and can be listed with the ls -la command

5. Installing the MediWiki update

  • We should be in the /mw working directory. The next command will unpack and copy over the update to the installed (live) directory of the MediaWiki install. For my server, the MediaWiki install lives at /var/www/html so my command will include this path. If your install is somewhere else, you will need to modify the command
  • The command to install the update is
    sudo tar xvzf mediawiki-1.36.0.tar.gz -C /var/www/html/ --strip-components=1
  • NOTES: The link provided earlier to MediaWiki on updating includes a different command to deflate the archive. Their version has not ever worked for any of the updates I have ever applied on any of my Debian based builds. The provided command in the line above is correct and gets the job done
  • NOTES: The above command is the same command used for building new MW servers too
  • Now that the command is completed, we need to run the update for PHP to complete the install. Don’t skip this setup, you’re only half done.

6. Running PHP update to complete the task

  • Now we need to make PHP look at the update to complete the changes and get the MediaWiki server back to working order
  • Currently we are in the /mw working directory. We can either run the next command from here or change to the maintenance directory and run the update from there
  • (Optional) list the contents of the MediaWiki install directory using
    ls -la /var/www/html - You should see a directory called maintenance
  • (Optional) list the contents of the MediaWiki maintenance directory using
    ls -la /var/www/html/maintenance - In this directory, you should see a file named update.php
  • Running the update from the /mw directory -
    sudo /var/www/html/maintenance/update.php
  • (Optional) running the update from within the maintenance directory
    cd /var/www/html/maintenance
    sudo ./update.php
  • The update will take a few seconds to run

7. Restart the Apache service and check the MediaWiki version from the website

  • Restart the Apache2 service with
    sudo systemctl start apache2
  • (Optional) if you want to verify the apache2 service is running use
    sudo systemctl status apache2 to verify
    Ctrl + C to exit
  • Open your MediaWiki server page and log in with an admin account.
  • To verify the version navigate to Special pages → Version (under data and tools section) - At the top under installed software section you should see MediaWiki and the new version next to it
  • Congratulations, you have updated your MediaWiki server


8. House Keeping

  • Delete the previous versions of updates or if you don’t want to keep the current update archive you can remove it too. In this example I remove the previous update file (1.35.2) from the /mw working directory
  • If you are not in the /mw directory you can either go there with
    cd /var/www/mw
    or you can issue the command with the path. If you need to know the name of the file to remove, use the
    ls -la /var/www/mw to list the contents
  • To remove the old update archive use
    sudo rm mediawiki-1.35.2.tar.gz while in the /mw directory
    or use
    sudo rm /var/www/mw/mediawiki-1.35.2.tar.gz
  • (Optional) to remove the current update archive use
    sudo rm mediawiki-1.36.0.tar.gz
    or while in the /mw directory or use
    sudo rm /var/www/mw/mediawiki-1.36.0.tar.gz

That looks very good thanks for posting.

1 Like