How to configure MediaWiki to use Memcached

In this tutorial we will explain how to configure your MediaWiki application to use Memcached. MediaWiki natively supports Memcached. This means that you just need to enable this option. In order to do this you have to edit the MediaWiki PHP configuration file - LocalSettings.php.

This file is stored inside the web root folder. For example, if your website is accessible at:

http://domain.com/wiki

this means that the LocalSettings.php file is in your public_html/wiki folder. In order to edit the file you can use the cPanel File Manager.

Open the file and find the following two lines of code (usually this is also the end of the file):

# End of automatically generated settings.# Add more configuration options below.

Right below them add the following lines:

$wgMainCacheType= CACHE_MEMCACHED;
$wgParserCacheType= CACHE_MEMCACHED;
$wgMessageCacheType= CACHE_MEMCACHED;
$wgMemCachedServers=array("127.0.0.1:11211");

Please note that you should replace port number 11211 with the correct port number for your hosting account.

For more details how to find out the correct port please check the following tutorial:

Enable Memcached from cPanel

After that save the file. The following screenshot shows how to edit the file via the cPanel File Manager -> Code Editor Tool:

That's it - your MediaWiki application is now correctly configured. From now on the wiki app will use Memcached to cache certain API calls, database calls and objects.