Quick and Dirty PECL for MAMP (os x)

I had to compile the pecl memcache today for work on my devel system. I already had MAMP installed so I just wanted to do a pecl install ... turns out that won't work. There's a few steps you need to do first. (Note: you must have gcc installed to get this to work. Also, I won't cover installing memcached, just compiling the pecl memcache extension and tyeing it into php.)

  • Using PECL to add to MAMP (OS X)
  • First download the right php source from php.net
    In /Applications/MAMP/bin/php5 create an include directory
  • Unzip/tar the php source archive and move it to /Applications/MAMP/bin/php5/include
    rename the php source directory to just php (so then it will look like /Applications/MAMP/bin/php5/include/php)
  • In terminal cd to /Applications/MAMP/bin/php5/include/php and type in ./configure
  • Once configure is done running cd back to /Applications/MAMP/bin/php5/bin
  • Run ./pecl i packagename (package name is the PECL package you want to install)
  • Once the compile is complete cd to /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-########/ (###### is the date)
  • Move the extension you just compiled to the first no-debug-non-zts-##### directory. (You should see other extensions in there)
  • Edit your php.ini file and add extension=packagename.so where the other extension= lines are.
  • Restart your MAMP and then check your php info page to make sure your package is listed as loaded.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

not finding header files

I am having trouble following your guideline.

So I created a "include" directory in /Applications/MAMP/bin/php5

Its already unclear what should happen in the next step. Should the source files end up in the "library" directory? It seems the source files should be in a directory called "php" inside the "library" directory. In that case however "./configure" needs to be called inside the "php" directory and not the "library" directory. At any rate in neither scenario does anything end up in the "include" dir and I end up with an error message that php_session.h cannot be found (and it appears pretty much all other files the command is looking for are also not found).

Correction: I'm not sure

Correction:

I'm not sure where I got "library" from. So much for my proof reading :(

/Applications/MAMP/bin/php5/include/php

Is where the ./configure should be run.

I'll update the orig post.

MAMP not load memcache

Yes, I have created memcache.so under PHP 5.2.1.

And I put it into extensions dir

But MAMP did not load memcache.so after restarting.

Do I have to recompile php?

mailparse extension

Thanks for writing this -- it really helped me. A couple problems came up though so I thought I should warn others:

1) When I was compiling the PECL extension, I got a compiler error: "C compiler cannot create executables". It turns out that I didn't have XCode tools fully installed (I had done a custom install and installed only what I thought I'd need). I reinstalled XCode tools using a default install and then it worked.

2) After I got past the compiler error I got an error "The mailparse extension requires the mbstring extension!". To solve this, I had to go back to the previous step and run ./configure --enable-mbstring=all

God, thank you SO much for

God, thank you SO much for this write-up.  This saved me hours and many headaches trying to get xdebug installed.

User login