How to install Memcached on CentOS (with DirectAdmin installed) + Memcached PECL

By BXTra |

After I was done with install Memcached on CentOS a while ago, I just know today that there are 2 different PECL modules. One is "Memcache PECL" while another is "Memcached PECL". The one I did before is "Memcache PECL", so, now, I try to install "Memcached PECL" which is newer and require libmemcached library.

The content below is almost exactly to my previous Memcache PECL installed. Only a few changes to install Memcached PECL instead.

Get Libevent which is require to install Memcached. Their homepage is here ->

tar -xvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure;make;make install;

Then, get Memcached from

gunzip memcached-1.4.5.tar.gz
tar -xvf memcached-1.4.5.tar
cd memcached-1.4.5
./configure;make;make install;

For me, I got an error below :

error while loading shared libraries: cannot open shared object file: No such file or directory

So, I did steps below :

nano /etc/

Then, enter into the textbox


Then, CTRL+O to save, CTRL+X to exit.

Then, run


Once you're done with that, try run

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

This is not done yet, you need to let PHP knows to be able to use memcached.

tar -zxvf libmemcached-0.40.tar.gz
cd libmemcached-0.40

You will see screen below :

Then, run

make && make install

Then install Memcached PECL with below command :

pecl install memcached

Once it's done, you will see the screen below:

With above picture, you may notice that the extension path is different to what we normally see. The path in the picture say :


But what most module for PHP 5.2 installed will compile into


Therefore, make sure you get the right path for extension_dir Edit php.ini to have lines below : (Make sure the line "extension_dir" is there or you need a full path to )

extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"

Then, restart HTTP and check PHP Status.. You will see Memcached info as below:

In case you need to use Memcached as a session handler. (Not require) Then, you need to edit php.ini and set variable below :


Now, you're done install Memcached on the server. However, you need to modify some code in your website script to make use of Memcached.


Server Information - Software - CentOS 5.4
- DirectAdmin 1.351
- Apache 2.2.15
- PHP 5.2.13
- MySQL 5.1.45

Source : -

clients/ms_thread.o:/home/dcardin/build/libmemcached-0.37/clients/ms_thread.c:198: more undefined references to `__sync_fetch_and_add_4′ follow see:

Add new comment

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.