How to install Memcached Server on Mac OS With Examples

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

Install Memcached on Mac OS

Memcached is a memory based caching mechanism and build using C language. To install memcached server on Mac OS, 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 lib events library.

Steps are;

Once libevents is installed then you can install Memcached server.

Steps are;

Now Memcached server is installed in your system. If the libevent library is not installed, configure command will give the following error.

install-memcached-mac.png

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.

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)

Or, provide it’s path using --with-libevent option in configure command.

I have used the above steps to install Memcached server on Mac OS. If you face any issues, let me know. I will try to resolve them.

Happy Caching…

Further Reading: Install Memcached on CentOS and PHP integration

References:

By admin

Leave a Reply