Memcache(d) is a object caching system that stores data in RAM to reduce the number of times something has to be read. It is generally used to speed up dynamic database-driven websites.
First thing to do is make sure you have the correct repository installed with:
rpm -Uvh http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
To install memcache you can use the following:
yum install -y memcached
and then turn it on from server boot:
chkconfig memcached on
Now we need to make some configuration changes by editing /etc/sysconfig/memcached and you should see something similar to:
PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS=""
You should then update the options section to:
You will now need to install the php module.
yum groupinstall “Development Tools”
yum install zlib-devel libmemcached-devel php-pear php-pecl-memcached
Once you have done this you will need to edit your php.ini file found at /etc/php.ini
You should then locate the following section:
[Session] ; Handler used to store/retrieve data. ; http://www.php.net/manual/en/session.configuration.php#ini.session.save-handler session.save_handler = files
You should change this section to the following:
[Session] ; Handler used to store/retrieve data. ; http://www.php.net/manual/en/session.configuration.php#ini.session.save-handler session.save_handler = memcached session.save_path = "127.0.0.1:11211"
Restart apache and your done!
You may get a message when restarting apache similar to:
Starting httpd: httpd: apr_sockaddr_info_get() failed for memcached httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
This can be resolved by editing /etc/httpd/conf/httpd.conf and commenting or adding the following line
Is memcache running?
If you log into your server as a user (not root) and run the following command it will tell you what is being cached by memcache