Installing Memcached on Centos 5

The following post is a tutorial on how to install memcached and memcache php extension on Centos 5. Before you start there are a few useful points that might come in handing if you come across any errors.

php.ini file is kept in


To find out where your php.ini file is kept you can type the following command

php -i | grep php.ini

The default extensions loaded are kept in this folder


The actual php extensions are kept in


Install Memcached

Enable the following repository.

For i386 / i686

rpm -Uhv

For x86_64

rpm -Uhv

Use the command Yum to install memcached

yum -y install memcached

If no error popup then you have successfully installed memcache. You should then configure memcache by typing the following command.

vi /etc/sysconfig/memcached

you should see:

PORT="11211"    #define on which port to urn
USER="nobody"   #same as apache user
MAXCONN="1024"  #maximum number of connections allowed
CACHESIZE="64"   #memory used for caching
OPTIONS=""   #use for any custom options

Start memcached

/etc/init.d/memcached start

Check it running

/etc/init.d/memcached status


netstat -anp | grep 11211

To stop / restart memcache

service memcached stop
service memcached restart

To See Memory Memcached Slabs

memcached-tool IP_ADDRESS:Port
memcached-tool IP_ADDRESS:Port display

To See Memory Memcached Stats

memcached-tool IP_Address:Port stats
memcached-tool stats

Install Memcache PHP Extension

Download and install lastest memcache version.

cd /usr/src
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
make install

“configure: error: no acceptable C compiler found in $PATH”

If for some reason the above code errors saying something like you do not have a compiler installed run the following command.

yum install gcc

Add memcache extension to php.ini file (depending on your version of PHP you may not need this step)

vi /etc/php.ini



Scroll don until you see a large block of code saying extension = …. Then add the following

extension = ""

To check memcache is correctly installed with php

php -i | grep memcache

Finally Restart Apache

/etc/init.d/apache2 restart

Special Thanks

This post would not have been possible without the follow tutorials and articles. I highly recommend you check them out as they list different techniques and include other information like how to start memcache as a service.