About Liquid Web

A Leader In Managed Hosting since 1997

Our Heroic Support technicians are located on-site at each of our data centers.
Liquid Web Knowledge Base

Knowledge Base


Install memcached on CentOS 5
Filed under: Technical Support

Memcached is a distributed, high-performance, in-memory caching system that is primarily used to speed up database-heavy sites, but can be used to stores objects of any kind.

Nearly every popular CMS has a plugin or module to take advantage of it, and many programming languages have a memcached library, including PHP, Perl, Ruby and Python. Memcached runs in-memory and doesn’t need to write to disk, so it is incredibly fast. We’ll discuss setting up memcached for specific CMSes in later articles, but for now let’s get memcached up and running on your CentOS 5 server.

First, we start with installing libevent; at least version 1.1 is required. This one’s easy, we can install it using yum.

yum install libevent libevent-devel

Now, onto memcached. Change your working directory to /usr/local/src and download the memcached source:

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

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

tar xvzf memcached-1.4.1.tar.gz
cd memcached-1.4.1

Memcached is actively developed, so the version used in this tutorial may be out of date by the time you read this. As of this writing, 1.4.1 is the latest stable version. Check http://danga.com/memcached/download.bml for a newer version before proceeding with the installation.

Up next, configuring our Makefile. This can be as simple as:

./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 mutli-core CPUs, enable threading:

./configure --enable-threads

If you’ve got both a 64-bit OS and multiple CPUs, use both:

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

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!

===

Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434
support@liquidweb.com
https://manage.liquidweb.com/

Be Sociable, Share!




Copyright © 2011 Liquid Web, Inc. All Rights Reserved.