Install Memcached on cPanel server

First of all install the libevent

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
Show 1 Comment

1 Comment

Comments are closed