How to install Memcached on a CentOS

Reading Time: < 1 minute

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings or objects) from results of database calls, API calls, or page rendering.  Memcached will store sessions in memory instead of files. Because memory is way faster than reading a file your website will perform better and reduce load time.

Update the repositories

yum update -y

Start the installation

yum install memcached

Configure Memcached

vi /etc/sysconfig/memcached

Start Memcached
chkconfig --levels 235 memcached on
/etc/init.d/memcached start

Memcached PHP Extension

First you need to Install Pecl

yum install php-pear
yum install php-pecl-memcache

Restart Apache

/etc/init.d/httpd restart

Check Memcached plugin in PHP and enjoy it!

php -i | grep memcach
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.default_timeout_ms => 1000 => 1000
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user sqlite memcache