You are here: Home / Debian GNU/Linux / Servers / Databases / Install Memcached on Debian

Install Memcached on Debian

by Pierre-Yves Landuré last modified Aug 09, 2013 07:28

Memcached is a key/value database server easing the cache of objects in memory. It is largely used by some PHP CMS (Wordpress, Drupal, Prestashop, ...) for it bring a visible performance boost on server with available RAM. This howto ease the installation of Memcached on Debian

This howto is tested on :

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy


Provide the cache size (in MB):



Install the software:

command apt-get install memcached

The server is now working.

Raise the memory cache size

Apply the configuration :

if [ -n "${MEMCACHE_SIZE}" ]; then
command sed -i -e "s/^-m .*/-m ${MEMCACHE_SIZE}/" \

Restart the server :

/etc/init.d/memcached restart

Allow access from the network (dangerous)

This setup is dangerous and can lead to security breaches. Use it only if you know what you are doing !

In order to use the Memcached server from other network hosts, comment the "-l" option :

command sed -i -e "s/^-l /#-l /" \

Restart the server :

/etc/init.d/memcached restart

Note : to disable this configuration, use :

command sed -i -e "s/^#-l .*/-l" \
/etc/init.d/memcached restart


The memcached-tool command display Memcached statistics.

Disply the current memory cache state :

/usr/share/memcached/scripts/memcached-tool display

Display the server load statistics :

/usr/share/memcached/scripts/memcached-tool stats

Dump the cache contents :

/usr/share/memcached/scripts/memcached-tool dump

The Munin monitoring server can graph the Memcached server usage across time.