Note:
Please note that this article is considered legacy documentation because CentOS 5 has reached its end-of-life support.
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 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:
./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 you’ve got both a 64-bit OS and multiple CPUs, use both:
./configure --enable-threads --enable-64bit
Once the configuration script completes, build and install memcached:
make && make install
Finally, 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 background daemon process
- -u
- Specify the user that you want to run memcached
- -m
- Set the memory that you want to be allocated by memcached
- -p
- The port on which memcached will listen.