fter 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 -> http://www.monkey.org/~provos/libevent/
1
2
3
4
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz
tar -xvf libevent-2.0.16-stable.tar.gz
cd libevent-2.0.16-stable
./configure;make;make install;
Then, get Memcached from http://memcached.org
1
2
3
4
5
wget http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz
gunzip memcached-1.4.10.tar.gz
tar -xvf memcached-1.4.10.tar
cd memcached-1.4.10
./configure;make;make install;
For me, I got an error below :
error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
So, I did steps below :
1
nano /etc/ld.so.conf.d/libevent-i386.conf
Then, enter into the textbox
1
/usr/local/lib/
Then, CTRL+O to save, CTRL+X to exit.
Then, run
1
ldconfig
Once you’re done with that, try run
1
memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
This is not done yet, you need to let PHP knows to be able to use memcached.
1
2
3
4
wget http://launchpad.net/libmemcached/1.0/1.0.2/+download/libmemcached-1.0.2.tar.gz
tar -zxvf libmemcached-0.40.tar.gz
cd libmemcached-0.40
./configure
You will see screen below :
Then, run
make && make install
Then install Memcached PECL with below command :
1
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 :
/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613
But what most module for PHP 5.2 installed will compile into
/usr/local/lib/php/extensions/no-debug-non-zts-20060613
Therefore, make sure you get the right path for extension_dirEdit php.ini to have lines below : (Make sure the line “extension_dir” is there or you need a full path to memcached.so )
1
2
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
extension=memcached.so
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 :
1
2
session.save_handler=memcached
session.save_path="127.0.0.1:11211"
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