MacOS – PHP 5.4 Installation on Mountain Lion

macosPHPterminal

I just installed Mountain Lion, and of course I've had to set up Xcode Command Line Tools, reinstall Git, and do other things to get up and running again for programming. Naturally, PHP was pushed back to 5.3 from 5.4 that I previously had installed when my MacBook Pro was running Lion. I ran through the process downloading PHP 5.4, unzipping it (tar xf php5.4), configuring it (./configure with and without options), making it (make), running the make test (make test), and installing the make (sudo make install). When I ran configuration with options it did not allow me to make and when I ran without configuration options it failed to pass make test a few times (when this occurred I sent the information to Zend). When it did pass make test though, it said that it installed successfully, but when I would check the version (php -v) it still comes up with PHP 5.3. I've done this almost nine times with restarts and re-downloading the package every time; no sauce. Does anyone have any ideas what could possibly be going wrong? Any help on this issue would be greatly appreciated.

Best Answer

I strongly suggest you use the package installer or use a full stack of configuration options when compiling, including the --prefix option so you know where the binary gets installed to.

I can only guess PHP 5.4 installed itself into /usr/local/bin or somewhere else and didn't just overwrite the default binary in /usr/bin. And you seem to have not modified your PATH variable to prioritise the bin directory of /usr/local with e.g. PATH="/usr/local/bin:$PATH" in your .bash_profile. So, it's expected running php will still use /usr/bin/php and not /usr/local/bin/php.

Alternatively, you could just symlink the new php binary to /usr/bin/php, (delete or rename the default binary before that):

ln -s /usr/local/bin/php /usr/bin/php