HowTo install memcached from sources on Linux
Install Libevent 1.3e
I will assume that you don’t have libevent installed already on your system. Your system might already have libevent installed, but normally you will have a very old version (for ex. on debian etch the packaged libevent is 1.1a that was released in 2005); in this case you will want to remove the system package first (for ex. on debian run: aptitude purge libevent1). If you have a recent version packaged by your linux distribution you should keep it and move on the next step to install directly memcached.
Download, and install the latest version of libevent (check for the latest version, and change if needed the versions bellow):
cd /usr/local/src
wget http://monkey.org/~provos/libevent-1.3e.tar.gz
cd libevent-1.3e
./configure
make
make install
This will install by default the libraries under /usr/local/lib/. If you want it in another place you can do that by passing to configure a different prefix.
Depending on your system you might have already /usr/local/lib included in your ld configuration. If this is not the case (like on my test debian box) you can add it inside /etc/ld.so.conf, or as a nice debian “thing†you can just create a new file inside /etc/ld.so.conf.d/ like:
vim /etc/ld.so.conf.d/libevent.conf
##add a line containing:
/usr/local/lib/
Regardless of your choice you should run ldconfig to complete this step:
ldconfig -v
(and check the output to be sure that the /usr/local/lib has been properly included).
Install Memcached 1.2.4
After we have libevent properly installed on the system we can proceed and install memcached. Download the latest stable version and install it using the following steps:
cd /usr/local/src
wget http://danga.com/memcached/dist/memcached-1.2.4.tar.gz
tar zxvf memcached-1.2.4.tar.gz
cd memcached-1.2.4
./configure
make
make install
The memcached binary will be also installed by default under /usr/local/bin/. You can start the daemon by simply running: /usr/local/bin/memcached. The basic memcached options are:
memcached -d [-m memory_in_megabytes [-l listen_ip_address [-p listen_port]]]
For ex:
memcached -d -m 256 -u nobody -p 11211 -l 192.168.0.1
will be used to run a memcached daemon bind on 192.168.0.1 on the default port 11211 using max 256MB memory.
