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
Uncompress the tarball and change into the directory that is created:
tar xvzf memcached-1.4.15.tar.gz
Check the latest version at http://memcached.org/ and change 1.4.15.tar.gz accordingly. Now make you config file.
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:
If your server has multiple CPUs or uses multi-core CPUs, enable threading:
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:
- Tell memcached to start up as a backgrounded daemon process
- Specify the user that you want to run memcached
- Set the memory that you want to be allocated my memcached
- The port on which memcached will listen.
And that’s it. Now go forth and speed up your sites!