Memcached is an open source high performance distributed memory object caching system. It is one of the most widely used cache mechanism used by some of the biggest websites like WordPress.com and LiveJournal.com.
It is also used by VBulletin software, for faster performance, that is one of the best software for Forums. It’s easy to install and there are so many client programs available on the Internet in different languages.
Read: Memcached Java Client
Table of Contents
Install Memcached on Mac OS
Memcached is a memory based caching mechanism and build using C language. To install memcached server on Mac OS or Linux we need C library. Here I am assuming that C library is already present in the system. If it’s not, then you can download C compiler and install it or install XCode that installs GCC compiler with it.
After that, you need to install the libevents library.
$ curl -OL https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz $ tar -xvf libevent-2.1.8-stable.tar.gz $ cd libevent-2.1.8-stable $ ./configure --prefix=/usr/local $ make $ sudo make install
Once libevents is installed then you can install memcached server.
$ curl -O https://memcached.org/files/memcached-1.5.0.tar.gz $ tar -xvf memcached-1.5.0.tar.gz $ cd memcached-1.5.0 $ ./configure --prefix=/usr/local $ make $ sudo make install Password: $
Now Memcached server is installed in your system. If the libevent library is not installed, configure command will give the following error.
$ ./configure --prefix=/usr/local ... checking for libevent directory... configure: error: libevent is required. You can get it from https://www.monkey.org/~provos/libevent/ If it's already installed, specify its path using --with-libevent=/dir/ pankaj:memcached-1.5.0 pankaj$
Memcached Server on Different Port
By default, memcached server runs on TCP port 11211 and listens on UDP port 11211 and you can run multiple instances of memcached server from one installation.
Above command will start the Memcached server on TCP port 11211 and listens on UDP port 11211 as a daemon process.
$memcached -p 11111 -U 11111 -d
Above command will start the Memcached server on TCP port 11111 and listens on UDP port 11111 as a daemon process.
Test Memcached Server using Telnet
Next step is to use memcached telnet commands to test that it’s working fine.
In some of the Linux systems, you also need to add the libevent library location in the path.
If you get following error in starting memcached server:
./memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
Then add following configuration in user profile (for example, .bash_profile or .profile)
$export LD_LIBRARY_PATH= /usr/local/lib
Or, provide it’s path using
--with-libevent option in configure command.
I have used the above steps to install Memcached server in Linux and Mac OS systems. If you face any issues, let me know. I will try to resolve them.
Further Reading: Install Memcached on CentOS and PHP integration