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 tying 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.

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.
More anon praise. It's the
More anon praise. It's the simple things that can save someone else so much time. Would be nice if MAMP had a pecl interface built in. But this was simple enough, and besides, I prefer the cmd line.
Hi, No matter what I do I
Hi,
No matter what I do I keep getting the same error in my PHP log...
Unable to load dynamic library '/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/memcache.so' - (null) in Unknown on line 0
I've read that's because I'm using the wrong version of PHP, but my MAMP settings say 5.2.11, while Snow Leopard apparently natively has 5.3 installed. I've tried both to absolutely no avail... any ideas?
Thanks,
--d
Thanks for the info. I
Thanks for the info. I needed to perform a couple of extra steps and one variation.
1. export PATH=/Applications/MAMP/bin/php5/bin:$PATH
Without this pecl installs into /usr/lib/php/extensions/no-debug-non-zts-somedate
2. export PHP_PEAR_PHP_BIN=/Applications/MAMP/bin/php5/bin/php
Might be unnecessary but hey.
3. sudo ./pecl i packagename
Without the sudo, pear fails to install documentation into /usr/local/PEAR/docs. This is a bit fishy as I'd expect it to be installed somewhere under /MAMP. However the critical bits worked:
i. the extension was installed under /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/
ii. the extension was built against the correct version of php
iii. it worked
hoorah. back to coding.
THANK YOU THANK YOU! i spent
THANK YOU THANK YOU!
i spent the entire day banging my head against the wall