Memcached/MediaWiki: Difference between revisions
Antonizoon (talk | contribs) (Created page with "== Activating Memcached == Memcached is an alternative to the default APCu PHP caching system, and is designed to significantly lighten the load of queries on the database. A...") |
Antonizoon (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
Memcached is an alternative to the default APCu PHP caching system, and is designed to significantly lighten the load of queries on the database. Also, the [[mediawikiwiki:Extension:OAuth|OAuth]] extension requires memcached. | |||
Memcached temporarily stores data from a database query in memory so that it can be quickly retrieved as necessary. | |||
* Debian/Ubuntu: {{ic|sudo apt-get install memcached}} | |||
* RHEL/CentOS: {{ic|sudo yum install memcached}} | |||
By default memcached has only 64MB of memory allocated. Performance can be enhanced if you allocate it more memory, depending on how much you have and how large your database is. For example, to set this limit to 128MB, edit /etc/memcached.conf . Find this section in the file, and change ''-m 64'' to ''-m 128'', or whatever you prefer. | |||
{{hc|/etc/memcached.conf|<nowiki> | |||
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default | |||
# Note that the daemon will grow to this size, but does not start out holding this much | |||
# memory | |||
-m 64 # change this to 128 | |||
</nowiki>}} | |||
Now, start the memcached service with default port and settings: | |||
{{bc|sudo systemctl start memcached}} | |||
Check that memcached is running: | |||
{{bc|<nowiki>ps -eaf | grep memcached</nowiki>}} | |||
Add memcached support to your MediaWiki install by editing LocalSettings.php: | |||
{{hc|/var/www/mediawiki/LocalSettings.php|<nowiki> | |||
$wgMainCacheType = CACHE_MEMCACHED; | |||
$wgParserCacheType = CACHE_MEMCACHED; # optional | |||
$wgMessageCacheType = CACHE_MEMCACHED; # optional | |||
$wgMemCachedServers = array( "127.0.0.1:11211" ); | |||
$wgSessionsInObjectCache = true; # optional | |||
$wgSessionCacheType = CACHE_MEMCACHED; # optional | |||
</nowiki>}} | |||
If everything is working, enable memcached to run at every startup: | |||
{{bc|sudo systemctl enable memcached}} | |||
== Sources == | |||
https://www.mediawiki.org/wiki/Memcached#Setup | https://www.mediawiki.org/wiki/Memcached#Setup | ||
https://www.howtoforge.com/install-memcached-and-php5-memcached-module-on-debian-6.0-squeeze | https://www.howtoforge.com/install-memcached-and-php5-memcached-module-on-debian-6.0-squeeze |
Latest revision as of 14:13, 9 April 2017
Memcached is an alternative to the default APCu PHP caching system, and is designed to significantly lighten the load of queries on the database. Also, the OAuth extension requires memcached.
Memcached temporarily stores data from a database query in memory so that it can be quickly retrieved as necessary.
- Debian/Ubuntu:
sudo apt-get install memcached
- RHEL/CentOS:
sudo yum install memcached
By default memcached has only 64MB of memory allocated. Performance can be enhanced if you allocate it more memory, depending on how much you have and how large your database is. For example, to set this limit to 128MB, edit /etc/memcached.conf . Find this section in the file, and change -m 64 to -m 128, or whatever you prefer.
/etc/memcached.conf
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default # Note that the daemon will grow to this size, but does not start out holding this much # memory -m 64 # change this to 128
Now, start the memcached service with default port and settings:
sudo systemctl start memcached
Check that memcached is running:
ps -eaf | grep memcached
Add memcached support to your MediaWiki install by editing LocalSettings.php:
/var/www/mediawiki/LocalSettings.php
$wgMainCacheType = CACHE_MEMCACHED; $wgParserCacheType = CACHE_MEMCACHED; # optional $wgMessageCacheType = CACHE_MEMCACHED; # optional $wgMemCachedServers = array( "127.0.0.1:11211" ); $wgSessionsInObjectCache = true; # optional $wgSessionCacheType = CACHE_MEMCACHED; # optional
If everything is working, enable memcached to run at every startup:
sudo systemctl enable memcached
Sources[edit]
https://www.mediawiki.org/wiki/Memcached#Setup
https://www.howtoforge.com/install-memcached-and-php5-memcached-module-on-debian-6.0-squeeze