This article will explain how you can install the latest memcached daemon (including the libevent library) on a linux system. The only prerequisite for memcached is libevent so we will have to install this first.
Note: the output of the commands in this article are taken from a Debian Etch system. They should work on any recent linux distribution, but depending from your version you might need to make some changes. The versions of memcached and libevent used in this article are the latest stable one existing at the time this was written. Check the download pages bellow, and if newer versions exists you will probably want to use them.
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):
1 2 3 4 5 6
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:
1 2 3
Regardless of your choice you should run ldconfig to complete this step:
(and check the output to be sure that the /usr/local/lib has been properly included).
Install Memcached 1.2.4
1 2 3 4 5 6 7
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:
will be used to run a memcached daemon bind on 192.168.0.1 on the default port 11211 using max 256MB memory.
I hope you found this article useful. If you prefer to install memcached from packages you might find these older posts useful: “Memcached 1.2.2 on Debian Etch”, and “Memcached 1.2.2 on Centos/RHEL”. if you are looking how to build the php memcache module you can find more information about that on my older postâ€¦