Memcache is an in-memory key-value pair storage system usually used as a caching layer. (hence the name, Mem-cache).


Debian (including Ubuntu):

sudo apt-get insatll memcached php5-memcached php5-memcache


sudo yum install memcached php-pecl-memcached php-pecl-memcache


Configuration is done in the config file, while each OS has their own config format, we only really care about the the port and cachesize options for a basic setup.

Port: This is obviously the port memcached runs on, change it if you don’t like it running on the default port, but either way, take note of this port.

Cache Size: This is the amount of memory (in MB) to take up before we start evicting items. Change this value to suit your needs based on your needs and available server memory.

The config file location depends on your OS.

Debian (including Ubuntu): /etc/memcached.conf
CentOS: /etc/sysconfig/memcached


Your install most like came with a service file, so start it using that.

Debian (including Ubuntu) and CentOS

service memcached restart

Further Resources

  1. For a handy memcached admin tool, try phpmemcacheadmin.
  2. To figure out the difference between memcache and memcached.


Web Server Optimizations