How To Install memcached on CentOS 6 – Tutorial

Memcached

You should must install memcached  if your website make heavy use of database. Memcached  is a distributed, high-performance, in-memory caching system. It can be used store object of any type. Most of CMS comes with plugin to take benefit of memcached and also many programming languages like PHP, Perl, Ruby, and Python have a library for memcached. Memcached runs in-memory and is thus quite speedy, since it does not need to write to disk.  

Here I am going to show you how to install memcached in  Centos 6:

1st of al you have install dependencies those are used by memcached. install  libevent using yum. Use below command. 

yum install libevent libevent-devel

To start installing memcached, change working directory to /usr/local/src and then download the latest memcached source. use below command

cd /usr/local/src
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz

Uncompress the tarball  and change into the directory that is created:

tar xvzf memcached-1.4.15.tar.gz
cd memcached-1.4.15

 Check the latest version at http://memcached.org/ and change 1.4.15.tar.gz accordingly. Now make you config file.

/configure

Additional configure flags are available and can improve performance if your server is capable. For 64-bit OSes, you can enable memcached to utilize a larger memory allocation than is possible with 32-bit OSes:

./configure --enable-64bit

If your server has multiple CPUs or uses multi-core CPUs, enable threading:

./configure --enable-threads

If your server supports it, you can use both flags:

./configure --enable-threads --enable-64bit

N.B.: if the configure script does not run, you may have to install compiling tools on your server. It is simple as

yum install gcc
yum install make

Once the configure script completes, build and install memcached:

make && make install

Last but not least, start a memcached server:

memcached -d -u nobody -m 512 -p 11211 127.0.0.1

Put another way, the previous command can be laid out like this:

memcached -d -u [user] -m [memory size] -p [port] [listening IP]

Let’s go over what each switch does in the above command:

-d
Tell memcached to start up as a backgrounded daemon process
-u
Specify the user that you want to run memcached
-m
Set the memory that you want to be allocated my memcached
-p
The port on which memcached will listen.

And that’s it. Now go forth and speed up your sites!

Share with

PinIt
submit to reddit

About Chandan Singh

Chandan Singh is CEO of MFT Info Services Pvt Ltd. He strongly believes in Sanatan and Vegetarianism. He is strong follower of Truth ... So Never believe in Indian National Congress.

Leave a Reply

Top