How to install memcache on linux server?

Or you can use following steps to install PECL memcache manually.memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load.

memcached is meant to work in concert with something like the MySQL query cache, not replace it. The two implementations excel at vastly different things: memcached is an object cache, while MySQL provides a query cache.

memcached is extremely fast. It uses libevent, which provides a mechanism to execute a callback function when a specific event occurs on a file descriptor, to scale to any number of open connections. On a modern Linux system memcached utilizes epoll, is completely non-blocking for network I/O, ensures memory never gets fragmented, and uses its own slab allocator and hash table to achieve 0(1) virtual memory allocation.

How it install it on Linux server ?

#curl -O http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
#tar -xzvf libevent-1.4.9-stable.tar.gz
#cd libevent*
#./configure
#make
#make install


Now let’s download the newest Memcached source

#curl -O http://www.danga.com/memcached/dist/memcached-1.3.0.tar.gz
#tar zxf memcached-1.3.0.tar.gz
#cd memcached-1.3.0
#./configure
#make
#make install


Then add /usr/local/lib to LD_LIBRARY_PATH in your .bash_profile

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH


How it Works

First, you start up the memcached daemon on as many spare machines as you have. The daemon has no configuration file, just a few command line options, only 3 or 4 of which you’ll likely use:

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 –u nobody


This starts memcached as a daemon (-d) on the IP address and port specified with -l and -p, respectively, running as the user nobody (-u), allocating 1024  for object storage (-m). You should adjust the amount of storage to suit your needs; many memcached installs run with 4 GB. Once you are comfortable with your startup options, add the appropriate command to your startup scripts.

Create a /etc/init.d/memcached file and add above line to start memcached when the server boots With memcached installed and running, it’s time to get PHP talking to the object cache. While multiple PHP API exists, the one in the PECL repository is recommended. If you are running a newer version of PHP, installation is as simple as:

# pecl install memcache


Or you can use following steps to install PECL memcache manually.

#cd /usr/local/src
#curl -O http://pecl.php.net/get/memcache
#tar zxvf memcache*
#cd memcache-*
#phpize
#./configure
#make && make install


Now we have to make sure PHP loads the newly built memcache.so library by adding the following line to php.ini:

extension=memcache.so 

Now restart Apache:

Service httpd restart


Once it sucussfully install you can create phpinfo() on your webserver should now confirm that memcache is installed.

  • 34 Users Found This Useful
Was this answer helpful?

Related Articles

 How To Configure CSF Firewall

    In this how to I will describe how to install /configure full feature firewall on...

 How to remove the blocked ip using iptables

  First check that ip is blocked or not   iptables –L –n | grep   DROP all...

 Install RED5 Server on Centos 5.3

In this how to i will describe how to install RED5 server on Centos 5.3. This how to can be used...

 HowTo install and configure FFmpeg and FFmpeg-Php on a DA server

I saw this headline on another part of the forum and the instructions I thought were a lot more...

 HowTo install and configure FFmpeg and FFmpeg-Php on a DA server

I saw this headline on another part of the forum and the instructions I thought were a lot more...