On dynamic websites is highly recommended a cached system. There are several methods how to implement a cached system but in this article we will show how to install Memcached. Memcached is a general-purpose distributed memory caching system that was originally developed by Danga Interactive for LiveJournal, but is now used by many other sites. It speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. Memcached runs on Unix, Linux, Windows and Mac OS X and is distributed under a permissive free software licens.
Install Memcached package
First you must add Remi Repository (You don’t need if you are running on Fedora)
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
yum install memcached (ubuntu) apt-get install memcached
Now you must open the configuration file with the following command:
If you are new to vi/vim editor, check out this video tutorial how to use vi Editor
PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="512" OPTIONS=""
It is important to set the CACHESIZE at “good” value. In this example i have used 512MB.
Start automatically Memcached
This command will set Memcached to start automatically on system boot
chkconfig memcached on # Start Memcached service memcached start
Install Memcache Module and PHP
yum install php php-pecl-memcache
Restart Web server
Now the only thing you have to do is restarting your web-server with the following command.
service httpd restart