How to install memcached on CentOS

Added on: 2011-11-12 16:35:39 by: Emanuel

This article will help you install memcached on CentOS, in particularly Hostgator's CentOS 5.7 i686 standard. For the installation to work you must have root access privileges. You must also be able to use shell or connect through ssh using a program like PuTTy.

We are going to start by making a new folder named memcached:

mkdir ~/memcached
cd ~/memcached
Next we need to get the latest Libevent version because Memcached requires libevent to handle its network IO stuff:
tar xvfz libevent-2.0.15-stable.tar.gz
cd libevent-2.0.15-stable
./configure –prefix=/usr/local; make; make install
Next we need to manually load the libevent library file into the system via the ld configuration:
vim /etc/
enter /usr/local/lib/ and save using :wq ; afterwards you need to reload the ld configuration:
Now we are ready to get memcached since all its dependencies are installed:
cd ..
tar xvfz memcached-1.4.10.tar.gz
cd memcached-1.4.10
./configure;make && make test;sudo make install
Start memcached using:
memcached -d -u nobody -m 512 -p 11211
Getting to this point we have memcached installed. However we still need a way to talk to it. This is where the client APIs come into picture. We will be using the PHP API, so we will install the PHP memcache extenstion.
cd ..
tar xvfz memcache-2.2.6.tgz
cd memcache-2.2.6
./configure;make;make install
Let's now enable the extension in php.ini. First we must find our php.ini file:
php -i | grep php.ini
and then add extension = "" to it using vim. All that is left to do is restart the apache server:
httpd restart
And voila, you can start alleviating database load.

DownloadsArea Newsletter

Subscribe now and get all the important articles delivered directly to you.

More articles