Install Memcached on cPanel server

[Total: 5    Average: 5/5]

Today we will install Memcached on cPanel server , First of all install the libevent and once it’s installed we will install memcached on cpanel server.

Install Memcached on cPanel serverMemcached is a high performing caching system, which distributes memory objects. In other words, it is a provision for users to store data into a web page, in a ‘temporary cache’. This saves the user the hassle of having to run database queries and getting data from the database. It there is a memcache available, a user can extract data from the memcache. This method lets user’s construct a highly optimized application


tar zxvf  libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
make install
cd ..

Then installed memcached

tar zxvf memcached-1.4.15.tar.gz
cd memcached-1.4.15
make install
echo "/usr/local/lib/" > /etc/

Now run the following commands

memcached -d -u nobody -m 1024 -p 11211

Now install the memcached

tar zxvf libmemcached-1.0.17.tar.gz
cd libmemcached-1.0.17
make && make install
make && make install

Then run the following to check if is installed into /usr/local/lib/php.ini file and add it if is it not:

grep -q "" /usr/local/lib/php.ini || echo '' >> /usr/local/lib/php.ini

You can check the extension directory you are using and whether it is in it using this line:

for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do ls -lah $i/memcache* ;done

Also, to preserve the module on EasyApache recompiles, this needs to be done as well:

for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do cp $i/ /root ;done
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do echo -e '#!/bin/bash\ncp /root/' "$i\ngrep -q '' /usr/local/lib/php.ini || echo '' >> /usr/local/lib/php.ini\n/etc/init.d/httpd restart" > /usr/local/cpanel/scripts/posteasyapache ;done
chmod +x /usr/local/cpanel/scripts/posteasyapache

This will create a posteasyapache script that will ensure is copied from /root/ back into the php extension directory.

I followed the above details, and it shows up installed onto my machine:

root@host [~]# php -i | grep -i memcached
memcached support => enabled
libmemcached version => 1.0.4
Registered save handlers => files user sqlite memcached