Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Last active July 4, 2021 16:09
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • 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.

@rhache
Copy link

rhache commented Mar 27, 2013

Sorry, perhaps a noob question, but step 5 and 6 are not clear. Are we supposed to cd to those directories?

@rhache
Copy link

rhache commented Mar 27, 2013

Also, step 7 in MAMP PRO should be "in MAMP PRO, go to File > Edit Template > PHP > YOUR PHP VERSION"

@markovic131
Copy link

Thank you!

@juliescript
Copy link

Thanks! This worked perfectly well after 2 days of trying to install memcached with other tutorials.

@kyletaylored
Copy link

This guy has it down pretty well, especially with just using brew. https://github.com/majksner/php-memcached-mamp

@Dezinger
Copy link

How setup autorun memcached with MAMP PRO?

@knittos
Copy link

knittos commented Sep 6, 2013

@up:
To have launchd start memcached at login:
ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents
Then to load memcached now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
Or, if you don't want/need launchctl, you can just run:
/usr/local/opt/memcached/bin/memcached

@jakebellacera
Copy link
Author

@Dezinger - memcached is a separate process that needs to be started manually or automatically via launchctl using the commands that @knittos provided. The PHP memcached extension is, just that, an extension, that connects to memcached when it's running.

@100terres
Copy link

What about MAMP PRO 3?

@allenkung
Copy link

Really helped a lot, thanks!

@sineld
Copy link

sineld commented Mar 20, 2014

Worked for me.
Thanks

@ahpay
Copy link

ahpay commented Apr 10, 2014

MAMP PRO 3.0.3 is can't works

@riteshgurung
Copy link

Did anyone found a way to make it work for MAMP PRO 3.0.3?

@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