MediaWIKI Upgrade
Jump to navigation Jump to search

There are all sorts of tutorials on upgrading MediaWiki. Here's the "down and dirty" version.

NOTE: As of 2020 and MediaWiki 1.35.0, the Visual Editor is include within the MediaWiki package. And it works out of the box for HTTP and HTTPS (dang that used to be difficult to figure out how to install and then configure to use with STUNNEL).


Don't take a chance that the upgrade will mess something up. Make a backup. For MediaWiki, that consists of two items: The website files and the data base.

Backup the website files (actually make a copy)

mv WebSiteDirectory WebSiteDirectory.WorkingVersionX.YZ
...then copy to original files over the expanded upgrade files (see steps later)

The above is the quickest way to make an exact copy of the website files (unlike NTFS, Linux permissions are simple and will be copied with the above command) and also test as you go. IE, the copied files can be checked for functionality by going to the web site.

For the database, use the command line or phpMyAdmin. phpMyAdmin makes it really easy. Select the database, export, simple, Go, save it, done.

Common Mistakes to Watch Out For

When unpacking the TAR file, remember it is named: mediawiki-W.XY.Z (not plain mediawiki), for example mediawiki-1.34.1

If any mistakes occur, remember to delete the new WebSiteDirectory if starting over: rm -R -f WhatEverDirectory


This is a good opportunity to upgrade PHP too. As of this writing, 5.2020, MediaWiki claims there is an issue with version 1.3.X of MediaWiki and PHP 7.4.X, so use 7.3.X

yum upgrade php73* (This will upgrade all relevant PHP version 7.3 modules if FCGI is being used)

Another Note: If multiple versions of PHP (7.2, 7.3, 7.4, etc.) are installed and using FCGI, when upgrading with yum upgrade php74*, will also upgrade the lower versions.

As of MediaWiki 1.34.1 they had an issue with PHP 7.4.0 - about 7.4.2, but as of 7.4.7, everything seems to work fine.

Upgrade (Actually Install and Copy)

Get the latest version (FULL version, not upgrade) of MediaWiki:

Before unpacking it, rename the original Directory of MediaWiki that is being upgraded to (see steps above in BackUp!)

Unpack the TAR File: tar -xvzf mediawiki-1.xy.0.tar.gz -C /var/www/html/WhatEverDirectory (Don't worry about making a mess with a lot of files as the TAR File's first item is a Directory, as it should be)

Rename it to the original WebSiteDirectory (as that Directory name was changed): mv mediawiki-1.xy.0 WebSiteDirectory

Set the proper file permissions for Apache (adjust as necessary for your environment);

chown -R apache:apache /var/www/html/WhatEverDirectory
find /var/www/html/WhatEverDirectory -type d -exec chmod 755 {} \;                      
find /var/www/html/WhatEverDirectory -type f -exec chmod 644 {} \;    
find /var/www/html/WhatEverDirectory/images -type d -exec chmod 755 {} \;
find /var/www/html/WhatEverDirectory/images -type f -exec chmod 755 {} \;

Copy previous version of MediaWiki website files into the new directory;

cp -R -n -v -a -x /var/www/html/WorkingWebSite/* /var/www/html/WebSite (Notice the * (Asterisk) for the Source Files)

Note: Flags can be combined, IE -Rnvax, but are shown separately for clarity.  Also, to just make a duplicate copy of a Directory: cp -ax Source Destination is the best route to go.

This will not overwrite any new files, IE "upgraded" files, but has the effect of copying all the extensions, images, and any other files from the old website version, while paying deference to the newer files.


Copy the old copy of the LocalSettings.php file into the upgrade directory as the "new one", if it exists, wouldn't be overwritten with the new copy process. See this for a tip on the LocalSettings.php file.


Make sure the /WhatEverPathToWiki/images permissions are writable for the Owner. IE, if the images Directory is owned by Apache, it needs to be writable. 777 works, 755 is recommended, but did not test with that.

Scribunto & Lua

If the Mediawiki software being upgraded uses the Scribunto and Lua extensions, then change permissions on the following file;

chmod a+x /var/www/html/WhatEverWebSite/extensions/Scribunto/includes/engines/LuaStandalone/binaries/lua5_1_5_linux_64_generic/lua

Older versions of Mediawiki use the below path;


Not doing the above item will hose the Wiki!

Login Error

If everything works, but an error similar to "...prevented, ...hijacking, ...error" comes up and prevents logging in, look for a small link under the error message that says "...use secure", click that and then try to login.

If that doesn't fix it, try changing a caching setting temporarily in the LocalSettings.php file

$wgMainCacheType = CACHE_ANYTHING;

Refresh the page after making the change, and try logging in again.

Modification of Files

Of course if any MediaWiki code files have been modified, the same modifications should be made to the new files, but this is rare.). Below are some examples;

To remove the "This page was lasted edited on..." from the bottom of each Wiki page: In /PathToWikiWebFiles/languages/i18n/en.json, empty the data field for "lastmodifiedat" "lastmodifiedatby"

Which contains this: "This page was last edited on $1, at $2."

Alternative for Modifying Files (CSS)

Instead of changing code in files, CSS can be used to modify visibility of elements on a MediaWiki Site. The below script can be placed in the LocalSettings.php file and modify what appears for anonymous users and logged in users (probably not necessary to change anything for logged in users.

function efAddSkinStyles(OutputPage &$out, Skin &$skin) {
    if(!$skin->getUser()->isLoggedIn()) {
        if ($skin->getSkinName() == 'vector') {
            $out->addInlineStyle('#ca-history { display:none; }');
            $out->addInlineStyle('#t-info { display:none; }');
            $out->addInlineStyle('#n-recentchanges { display:none; }');
            $out->addInlineStyle('#n-help-mediawiki { display:none; }');
            $out->addInlineStyle('#t-whatlinkshere { display:none; }');
            $out->addInlineStyle('#t-cite { display:none; }');
            $out->addInlineStyle('#t-recentchangeslinked { display:none; }');
            $out->addInlineStyle('#ca-talk { display:none; }');
            $out->addInlineStyle('#ca-viewsource { display:none; }');
            # $out->addInlineStyle('#footer-info-lastmod { display:none; }');
    } else {
        if ($skin->getSkinName() == 'vector') {
            # $out->addInlineStyle('#ca-view { }');
    return true;
$wgHooks['BeforePageDisplay'][] = 'efAddSkinStyles';

The "#footer-info-lastmod" ID that is commented out above will disable the display of "Last edited / Last modified" for anonymous users.


Upgrade extensions (if there are upgrades). Visual Editor is one that needs to be kept up. Hopefully nothing breaks for extensions that don't have upgrades available.