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.
Jan 26th, 2011, 5:05 am
Hi folks.. i gave this a shot for 15 mins and ran into the same issues as 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
.. solved this with his advice and then ran in the the png.h.. configure: error: png.h not found.
So checked out the page http://www.libpng.org/pub/png/libpng.html as marcelo suggested downloaded and started installing to realise a big red banner at the top of the site saying there was a prob in the last release that i had just tried to install…. so a long story but in short, im off to download the new version of MAMP haha
Still a good little exercise in php set up and builds, will have to look into having various php builds for testing, as an exercise in patience… cheers for everyones help!
Max
Sep 15th, 2011, 3:09 pm
I couldn’t get past the first step of these instructions:
“Run the phpinfo() function in a PHP script on your localhost or go to PHPMyAdmin and hunt down the configuration page.”
The first option: “Run the phpinfo() function in a PHP script ” is far too vague to be of any use and the second option of finding the config page on PHPMyAdmin is just plain wrong – the PHPMyAdmin doesn’t even provide access to the configuration page.
Please don’t be so vague and sloppy with the facts when attempting to explain a tricky subject like this. The result is your ‘help’ is misleading and not at all helpful.
Oct 11th, 2011, 12:57 pm
@Max:
I think the majority of php developers know what phpinfo() is, in case you dont here is a link to the php manual,
http://php.net/manual/en/function.phpinfo.php
it has an example on how to run it.
Something that comes to my attention is that compiling php from source might not be the solution that matches every skill level, you might want to keep your MAMP php version until they provide a newer version.
Also i think David was helpful enough, that it helped me, and others as you can read, he only described the steps that helped him get to where he needed, most of the time compiling libs from source is a tedious process that requires attention and a vast knowledge of what you are doing.
If you really need to get a copy of PHP 5.3 or newer i would recommend not using MAMP, as they tend to bundle with major and stable releases which is not that often, try searching for the Hombrew, MacPorts or the Fink projects, they are package managers that will help you install what you need through the command line, i hope this helped and at the very least answered your question so you can get your configure script


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.