Installing memcached on CentOS (cPanel)

Welcome to hell. No really, compared to installing memcached on Ubuntu, CentOSs really sucks. CentOS really sucks for package management.  Really sucks. Anyway, on to the point.

Here’s how I installed memcached on CentOS, which I mainly use for cPanel.

LibEvent

Memcache requires LibEvent. Go to their site and get the latest version.

[codesyntax lang=”bash”]
wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xvfz libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure && make && make install

Compile and Install Memcache

Now you can install Memcache. Again you should check their site for the latest version.

[codesyntax lang=”bash”]
wget http://www.danga.com/memcached/dist/memcached-1.4.4.tar.gz
tar xvfz memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure && make && make install

If you are unlucky, you might need this line instead

[codesyntax lang=”bash”]
./configure –with-lib-event=/usr/local && make && make install

This next bit is only required because the CentOS/memcached is nasty, test it.

[codesyntax lang=”bash”]
memcached

If it works, great! Skip this next bit.
If it doesn’t work and throws an error about shared libraries and such, you might need to do this

[codesyntax lang=”bash”]
echo /usr/local/lib/ >> /etc/ld.so.conf.d/libevent-i386.conf

Now we need to make it start on bootup.

[codesyntax lang=”bash”]

cp scripts/memcached.sysv /etc/init.d/memcached

chmod 755 /etc/init.d/memcached

mkdir /var/run/memcached

chkconfig memcached on

chkconfig –list | grep memcached

The last line should return “on” values for 0,2,3,4,5

Now you want to install the PHP extension for memcached? Har har. GLWT!

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

6 thoughts on “Installing memcached on CentOS (cPanel)”

  1. Make that “yum install memcached” no need at all to try and compile for source, and it will load the prerequisites. Just did it.

Leave a Reply

Your email address will not be published. Required fields are marked *