How To Use Memcached with MAMP



When using Windows the comparison is cut short: memcache appears to be the only client available. brew install memcache and man memcache are not available on mac.


The piece that does the backend work is called a “daemon” (think “service” in Windows-land), while the interface or client application is what you use to control or access the daemon. The daemon is most often named the same as the client, with the letter “d” appended to it. For example “imap” would be a client that connects to the “imapd” daemon.

Memcached is a caching daemon designed especially for  dynamic web applications to decrease database load by  storing objects in memory.

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.

PECL :: The PHP Extension Community Library

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions. To connect the memcached to PHP, there is an extension named memcache and one named memcached in PHP which are different extensions to access memcache or we can say PHP has two memcached libraries named memcache and memcached.



memcache ( memcached extension which allows to work with memcached through handy OO and procedural interfaces. Memcache has been around longer, does not require additional libraries, and has pre-compiled binaries ( for even windows.


memcached ( PHP extension for interfacing with memcached via libmemcached library. This extension uses libmemcached library to provide API for communicating with memcached servers. Memcached offers more methods but it also require external C/C++ libraries libmemcached ( to provide API for communicating with

memcached servers and also require to install libevent ( for it to compile. Memcached is a newer API, it also provide memcached as a session provider which could be great if you have a farm of server. memcached is a high-performance, distributed memory object caching system,

generic in nature, but intended for use in speeding up dynamic web applications

by alleviating database load.

The frustration here is caused by the author of the PHP extension which was badly named memcached, since it shares the same name as the actual daemon called memcached.


  1. Install memcached through
    1. brew install memcached

and after installation check with

  1. man memcached
  2. memcached -h
  • Install memcached dependencies
    1. brew install libmemcached
    2. brew install libevent
  • For PECL to work we need to prepare the build environment for extensions by making the PHP source available.
  • Check your desired version of PHP that you’d like to use in MAMP. This dropdown is located in the PHP tab in MAMP Control Panel.
  • Visit the Downloads Page on and download the source code. If your release isn’t listed, visit the Releases page.
  • $ mkdir /Applications/MAMP/bin/php/[php version folder]/include
  • $ mv ~/Downloads/[php version folder] /Applications/MAMP/bin/php/[php version folder]/include/php
  • Extract the source into a new directory in your PHP installation /Applications/MAMP/bin/php/[php version folder]/include/php and run the configure script.
  • $ cd /Applications/MAMP/bin/php/[php version folder]/include/php
  • $ ./configure or Run on console : /Applications/MAMP/bin/php/[php version folder]/include/php/configure
  • All being well, you should now be able to install PECL extensions.
  • Add PHP memcached extension,
    1. Run on console sudo /Applications/MAMP/bin/php/[php version folder]/bin/pecl i memcached
  • If you happen to get the WARNING: channel “” has updated its protocols, use “pecl channel-update” to update
    • Run /Applications/MAMP/bin/php/[php version folder]/bin/pecl channel-update
  • Add “” to php.ini /Applications/MAMP/bin/php/[your php version]/conf/php.ini
  • Restart Apache
  • Verify memcache is installed correctly by going to http://localhost/MAMP/phpinfo.php and⌘+F for “memcache”.
  • Once you have your local binaries properly configured, you can essentially install any other php extension by using that pecl binary. pear, php and phpize should work as well.


    Make sure pecl compiled the memcache extension to the correct place. It should be in a folder named: /Applications/MAMP/bin/php/[PHP VERSION FOLDER]/lib/php/extensions/no-debug-non-zts-20060613



    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s