How to install memcache

In the beginning we need to install libevent because of memcached dependency

Check if libevent is installed or not?

whereis libevent

If you don’t find it, then we need to install it.

wget http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz

tar xfz libevent-1.4.8-stable.tar.gz

cd libevent-1.4.8-stable

./configure &&  make && make install

ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib

Its time to install memcahced now

1. Download and install

wget http://danga.com/memcached/dist/memcached-1.2.6.tar.gz

tar xfz memcached-1.2.6.tar.gz

cd memcached-1.2.6

./configure && make && make install

2. Run Memcached as a daemon (d = daemon, m = memory, u = user, l = IP to listen to, p = port)

memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211

Note: Version Numbers mentioned here might be outdated, so do check for updated package to download.

3. Now we have installed and started the Memcache daemon, it’s time to install PHP client

PHP version should be 5.2.6 or higher

yum install php-devel php-pear

pecl install memcache

Edit /etc/php.ini to add extension=memcache.so

Restart httpd

/etc/init.d/httpd restart

Leave a Reply

Your email address will not be published. Required fields are marked *