Please note that this article is considered legacy documentation because CentOS 5 has reached its end-of-life support.
yum install libevent libevent-develNow, 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.gzUncompress the tarball you download and change into the directory that is created:
tar xvzf memcached-1.4.1.tar.gz cd memcached-1.4.1Memcached is actively developed, so the version used in this tutorial may be outdated by the time you read this. As of this writing, 1.4.1 is the latest stable version. Check here for a newer version before proceeding with the installation. Up next, configuring our makefile. This can be as simple as:
./configureAdditional 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-64bitIf your server has multiple CPUs or uses multi-core CPUs, enable threading:
./configure --enable-threadsIf you’ve got both a 64-bit OS and multiple CPUs, use both:
./configure --enable-threads --enable-64bitOnce the configuration script completes, build and install memcached:
make && make installFinally, start a memcached server:
memcached -d -u nobody -m 512 -p 11211 127.0.0.1Put 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 background daemon process
- Specify the user that you want to run memcached
- Set the memory that you want to be allocated by memcached
- The port on which memcached will listen.