Memcached is a distributed Memory caching system, it is probably the de facto standard of caching facility for high performance web applications. In short, it is a key-value store which runs entirely in the memory, so it’s extremely fast and also proven to be reliable to handle high traffic.
Steps to install on CentOS (just works!)
Run the following commands one by one in the terminal, this will install the memcached server, and the PHP “Memcahe” classes needed to be used by PHP applications.
1 2 3 4 5 6 | yum install memcached -y yum install php-pear php-devel zlib-devel libmemcached-devel php-peci-memcache gcc make -y pecl install memcache echo "extension=memcache.so" >> /etc/php.d/memcache.ini service memcached start service httpd restart |
Your PHP application should be able to use Memcached now! (I have tested this on a freshly created VPS, so it should work fine). If you want the latest PHP and Memcached, please install the Remi repo and use –enablerepo=remi.
Config the memcached service
1 2 3 4 5 | # Edit the following file vi /etc/sysconfig/memcached # Reload the service after you edit the config service memcached start |
To make Memcached runs when CentOS start
1 2 | # "on" to make it auto start during boot, "off" to reverse it chkconfig memcached on |