I just want to try if Memcached can really help my server load or not. So, I look around to find the way how to do it. There are a couple ways but to me, below are what I did to installed it.
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://pecl.php.net/get/memcache-2.2.5.tgz gzip -df memcache-2.2.5.tgz tar -xvf memcache-2.2.5.tar cd memcache-2.2.5 phpize ./configure;make;make install;
Then, edit php.ini file. Add line below into the file
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" extension=memcache.so
Then, restart HTTP and check PHP Status.. You will see Memcached info as below:
Now, you're done install Memcached on the server. However, to really make use of it, you need to modify some code in your website. If you don't. You don't really 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