All Linux HowTo's

Install Memcached for Magento (or any PHP site) on CentOS/Redhat

This article explains how to install and configure memcached for Magento (or any PHP site) on a Redhat or CentOS server.

Install memcached:

yum install memcached php-pecl-memcache -y

Now edit your “/etc/sysconfig/memcached” file to look something like this:

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="256"
## Accept connections from another server (192.168.1.2)?
#OPTIONS="-l 192.168.1.2 -L"

Finally set it to start on boot:

chkconfig memcached on

And start it now:

service memcached start

Now configure Magento to use memcahced. Edit the file “local.xml” which you will need to search for. Try “locate local.xml”. In that file, find the line that says “</config>” and add the following right ‘before’ that line:
TIP: You may already have these lines in your local.xml file so in that case just edit it to be like this.

<cache>
<backend>memcached</backend>
<slow_backend><![CDATA[File]]></slow_backend>
<memcached>
<servers>
<server>
<host><![CDATA[127.0.0.1]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
</server>
</servers>
<compression><![CDATA[0]]></compression>
<cache_dir><![CDATA[]]></cache_dir>
<hashed_directory_level><![CDATA[]]></hashed_directory_level>
<hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
<file_name_prefix><![CDATA[]]></file_name_prefix>
</memcached>
</cache>

Similar Posts: