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 -> http://www.monkey.org/~provos/libevent/
wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz tar -xvf libevent-1.4.13-stable.tar.gz cd libevent-1.4.13-stable ./configure;make;make install;
Then, get Memcached from http://memcached.org
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz 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: libevent-1.4.so.2: cannot open shared object file: No such file or directory
So, I did steps below :
Then, enter into the textbox
Then, CTRL+O to save, CTRL+X to exit.
Once you're done with that, try run
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.
wget http://launchpad.net/libmemcached/1.0/0.40/+download/libmemcached-0.40.tar.gz tar -zxvf libmemcached-0.40.tar.gz cd libmemcached-0.40 ./configure
You will see screen below :
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 memcached.so )
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 :
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 : - http://blog.ajohnstone.com/archives/installing-memcached/