Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Last active July 4, 2021 16:09
Show Gist options
  • Save jakebellacera/3997527 to your computer and use it in GitHub Desktop.
Save jakebellacera/3997527 to your computer and use it in GitHub Desktop.
How To Install Memcache on MAMP 2

How To Install Memcache on MAMP 2

Note: This is an old guide and may not work for newer versions of macOS. Please see comments below for additional steps.

  1. Install memcached. I'd suggest using homebrew. brew install memcached
  2. Select your desired version of PHP that you'd like to use in MAMP. This dropdown is located in the PHP tab in MAMP PRO.
  3. Visit the Downloads Page on php.net and download the source code. If your release isn't listed, visit the Releases page.
  4. Extract the source into /Applications/MAMP/bin/php/[php version folder]/include/php.
  5. /Applications/MAMP/bin/php/[php version folder]/include/php/configure
  6. /Applications/MAMP/bin/php/[php version folder]/bin/pecl i memcache.
  7. Add extension=memcache.so to your php.ini
    • MAMP Pro: /Applications/MAMP\ Pro/MAMP\ PRO.app/Contents/Resources/php[your php version].ini
    • MAMP: /Applications/MAMP/conf/php[your php version].ini
  8. Restart Apache, then 🍺.
  9. Verify memcache is installed correctly by going to http://localhost/MAMP/phpinfo.php and +F for "memcache".

Also...

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.

Troubleshooting

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


Inspired by this tutorial, and gisted in case it ever went down.

@himanshupathakpwd
Copy link

Yes I have enabled memcached for MAMP PRO 3.0.3 .. you just need to download php source code form and configure it in currently selected php version in mamp pro. Then run "pecl install memcached"

@iDevOrz
Copy link

iDevOrz commented Apr 14, 2017

/private/tmp/pear/temp/memcache/memcache.c:40:10: fatal error: 'ext/standard/php_smart_str.h' file not found
#include "ext/standard/php_smart_str.h"
^
1 error generated.
make: *** [memcache.lo] Error 1
ERROR: `make' failed

@mhulse
Copy link

mhulse commented Apr 26, 2017

Same problem as @Jatstar

@woprrr
Copy link

woprrr commented May 19, 2017

@Jatstar @mhulse you need to use : pecl install memcached and previously brew install libmemcached

@sigidhanafi
Copy link

sigidhanafi commented Oct 7, 2017

This is great solution.
But, that really I need to run memached is only to run
cd /Applications/MAMP/bin/php/[php version folder]/bin/
sudo ./pecl i memcache
and follow command line instructions
Then follow step 6

Thanks for this solution 👍

@adampatterson
Copy link

Not to take away any hard work here, but I think with macOS 11.1 this GISt helps, but still requires some extra steps

https://gist.github.com/Niteshvgupta/1832ce29dee460b64d5384e4f585e7ab

I left a comment because I ran into a number of errors as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment