Upgrading PHP in MAMP
I wanted to take advantage of PHP 5.3’s new
1 | namespace |
feature but in my localhost environment, I use MAMP. Upgrading PHP proved a little tricky, but actually very easy. The tricky part was figuring out how to make it work, but on the whole, it’s not too bad.
First, run the
1 | phpinfo() |
function in a PHP script on your localhost or go to PHPMyAdmin and hunt down the configuration page. You should see a large chunk of configuration markup at or near the top:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 './configure' '--with-mysql=/Applications/MAMP/Library'
'--with-apxs2=/Applications/MAMP/Library/bin/apxs'
'--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library'
'--with-png-dir=/Applications/MAMP/Library' '--with-zlib'
'--with-freetype-dir=/Applications/MAMP/Library'
'--prefix=/Applications/MAMP/bin/php5' '--exec-prefix=/Applications/MAMP/bin/php5'
'--sysconfdir=/Applications/MAMP/conf/php5' '--with-soap'
'--with-config-file-path=/Applications/MAMP/conf/php5'
'--enable-track-vars' '--enable-bcmath' '--enable-ftp' '--enable-gd-native-ttf'
'--with-bz2=/usr' '--with-ldap' '--with-mysqli=/Applications/MAMP/Library/bin/mysql_config'
'--with-sqlite' '--with-ttf' '--with-t1lib=/Applications/MAMP/Library'
'--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-dbx'
'--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2006i'
'--enable-soap' '--with-kerberos' '--enable-calendar'
'--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-dbase'
'--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library'
'--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library'
'--with-pdo-mysql=shared,/Applications/MAMP/Library' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg'
'--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl'
Copy and paste this whole chunk into your text editor and remove the single quotes (search and replace should do it). Look for the flag
1 | --with-pdo-mysql=shared,/Applications/MAMP/Library |
and replace it with:
1 --with-pdo-mysql=/Applications/MAMP/Library
If you don’t do this, you might end up with an
1 | ld: symbol(s) not found |
error.
Finally, add the following flag to the end:
1 --without-iconv
After you have downloaded the latest PHP release of your choosing from PHP Sources Snapshots,
1 | cd |
to the downloaded directory in Terminal. Paste your reformatted configuration string (all of it, including the beginning
1 | ./configure |
command) and run it.
After the configuration phase is finished, run:
1
2 $ make
$ sudo make install
Relaunch MAMP, and you’re good to go.
For you CakePHP users out there, now you can play with Cake3 releases (which apparently will be optimized for PHP 5.3+).
Comments
Aug 5th, 2009, 4:23 pm
Just guessing, but have you checked the –with-png-dir flag? You may also want to try using the latest 5.3 stable release instead of the 5.3-dev release.
Aug 28th, 2009, 1:10 am
Thanks for this instruction! One thing seems to be worng “or go to PHPMyAdmin ” Should be “or go to phpinfo”.
Khang Nguyen
Sep 4th, 2009, 1:44 pm
Hi David,
I followed your instruction but get the following error. Please advise. (Mac 10.5, Perl installed.)
Thanks,
Khang
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using –with-apxs2=/path/to/apxs
3. Apache was not built using –enable-so (the apxs usage page is displayed)
The output of /Applications/MAMP/Library/bin/apxs follows:
cannot open /Applications/MAMP/Library/build/config_vars.mk: No such file or directory at /Applications/MAMP/Library/bin/apxs line 218.
configure: error: Aborting
Khang Nguyen
Sep 4th, 2009, 2:02 pm
Fixed it. Change ‘–with-apxs2=/Applications/MAMP/Library/bin/apxs to –with-apxs2=/usr/sbin/apxs
Khang
Oct 26th, 2009, 8:44 am
On Snow Leopard, I get following error:
checking whether libxml build works… no
configure: error: build test failed. Please check the config.log for details
ld: warning: in /Applications/MAMP/Library/lib/libxml2.dylib, missing required architecture x86_64 in file
Dec 11th, 2009, 1:01 pm
tboley,
I’m having the same problem
ld: warning: in /Applications/MAMP/Library/lib/libxml2.dylib, missing required architecture x86_64 in file
Did you ever get this resolved? I’m on snow leopard.
JJ
Dec 14th, 2009, 2:51 am
Thanks Khang Nguyen for your follow-up on the Perl error :)
JJ
Dec 14th, 2009, 3:40 am
I can’t make it work; I get the error “configure: error: png.h” and I can’t find anything related to that in the interwebs, other than I need to install libpng and then change (I assume) change the ./configure parameter to point to the newly installed libpng.
But, if I need to do all that, then why is this article supposed to work right away? Did the author do something that is not mentioned, or is there something else wrong?
JJ
Dec 14th, 2009, 3:44 am
Also, if I remove the GD (and jpg, and png) parameters, I still get an error with “configure: error: Cannot locate header file libintl.h”.
I have XCode tools (3?) installed (not the latest, but at least from around March).
Dec 24th, 2009, 11:22 am
To fix the libxml error above set:
–with-libxml-dir=/usr/lib
Dec 24th, 2009, 2:51 pm
Most of these errors are caused by libraries not supporting 64bit. You need to get updated libraries.
First install fink:
http://www.finkproject.org/download/srcdist.php
and then run:
fink install libjpg
fink install libpng3
fink install libmcrypt
and then make sure that the following are set to: (where /sw is your fink directory)
–with-jpeg-dir=/sw –with-png-dir=/sw –with-gettext=/sw
> note >>> alternatively setting –with-png-dir=/usr/X11 also worked for me. This probably depends on whether your x11 library is up to date
Additionally I had to set:
–with-freetype-dir=/usr/X11
The fix for the libintl.h problem was in setting: –with-gettext=/sw
I also had to do
fink install mysql15-dev
And set: –with-mysql=/sw
Any other options that threw errors, I just removed, since I didn’t need them. Hope this helps.
Dec 26th, 2009, 11:29 am
And. I built it fine. But then there were make errors and I gave up and installed XAMP.
Vic
Mar 7th, 2010, 11:01 pm
After running the configure command i get this error
checking for cc… no
configure: error: no acceptable cc found in $PATH
Oleg
Mar 15th, 2010, 9:28 am
+1
got the same error as Vic :/
Oleg
Mar 15th, 2010, 10:17 am
i reinstalled my developer tools to resolve the $PATH error.
then ran into two more. turns out this is too much of a pain in the ass :/
Mar 17th, 2010, 2:36 am
There are some packages of libpng on this website http://www.libpng.org/pub/png/libpng.html
Jul 8th, 2010, 2:01 pm
+1 Thanks Khang Nguyen for your follow-up on the Perl error :)
Jul 26th, 2010, 12:23 am
For all those who come across this page now…
MAMP 1.9 has PHP 5.3.2 shipped by default, so no need to do follow these steps anymore.


Jose Diaz-Gonzalez
Aug 5th, 2009, 8:23 am
I get the following error on the configure:
configure: error: png.h not found.
Any ideas? I’m on Intel Leopard with php release php5.3-200908042230.