Compiling a PHP Memcache extension with MAMP 1.9.5
Any Drupal developer needing Memcached for local development has probably read Lullabot's famous Setup a Memcached-Enabled MAMP Sandbox Environment. It's a great primer, but if you are using a more recent version of MAMP, you may need newer instructions.
Here are the steps I took to get a memcache.so extension file for the two versions of PHP bundled with MAMP 1.9.5. Provided that you have Apple's Xcode Tools and PECL installed, you should be able to paste the following commands into Terminal. Or you can just download the files directly:
- /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
- /Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/memcache.so
PHP 5.3.5
pecl download memcache tar xvfz memcache-2.2.6.tgz && cd memcache-2.2.6 ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/include/ /Applications/MAMP/bin/php5.3/include /Applications/MAMP/bin/php5.3/bin/phpize MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Applications/MAMP/bin/php5.3/bin/php-config make cp modules/memcache.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/ rm /Applications/MAMP/bin/php5.3/include
PHP 5.2.17
pecl download memcache tar xvfz memcache-2.2.6.tgz && cd memcache-2.2.6 ln -s /Developer/SDKs/MacOSX10.5.sdk/usr/include/ /Applications/MAMP/bin/php5.2/include /Applications/MAMP/bin/php5.2/bin/phpize MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Applications/MAMP/bin/php5.2/bin/php-config make cp modules/memcache.so /Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/ rm /Applications/MAMP/bin/php5.2/include
Comments
Drew McGowen
Wed, 04/13/2011 - 19:48
Permalink
Sandbox setup
Hey this works great, I spent a considerable amount of time on the lullabot tutorial, but still had issues. This saved our developers a considerable amount of time.
Great blog, keep it up!
Roger Obando
Fri, 04/22/2011 - 14:47
Permalink
Thank you!
There are so many other tutorials about this online that lead me nowhere. Thanks so much for making it this easy!
dunghoangit
Mon, 05/09/2011 - 03:37
Permalink
Thank you so much! Great
Thank you so much! Great works, Great blog.
Sam
Fri, 09/23/2011 - 08:19
Permalink
Thanks!
Thanks so much for the direct downloads of the .so files. I couldn't get it to compile. Thanks again
Fabian
Sat, 11/26/2011 - 22:54
Permalink
It works!
Wow, finally a tutorial that works really great!
I tried 10s of others and always got an error with that one. Success at first try. Did work fine for getting xhprof to work as well!
Great job!
Oliver
Tue, 11/29/2011 - 02:47
Permalink
Works with MAMP 2.0.5
Great! This also works with MAMP 2 with PHP 5.2.17 and PHP 5.3.6.
Thank you very much for the compiled versions!
Add new comment