2

After upgrading to Mountain Lion I used this one line bash script to install php 5.4 http://php-osx.liip.ch/

It installs 5.4 to /usr/local/php5

If i run which php I get /usr/bin/php

And running php -v returns 5.3.13

How do tell Mountain Lion to use the php in /usr/local/php5

Will I also have to change Apache htttpd.conf to use the new version of php?

Thanks

ianckc
  • 1,716
  • 5
  • 18
  • 33
  • Personally, I'd recommend using [MAMP](http://www.mamp.info/en/index.html) rather than upgrading the native versions. If something goes wrong, it's just a reinstall of the software rather than the OS. – Dan Blows Aug 11 '12 at 10:22
  • I was running MAMP but had problems with xhprof so switched to using the native installations. – ianckc Aug 11 '12 at 10:23

1 Answers1

4

This is the hard way, you just link to the new php file:

$ sudo mv /usr/bin/php /usr/bin/php53 && sudo ln -s /usr/local/php5/bin/php /usr/bin/php

Change the php5 bin path according to the real php5 binary path since I have no idea where the correct binary is.

But I'd rather try to use just php5 on the command line since this is probably using the PHP5.4 version because /usr/local is usually in the $PATH as well.

You see which paths are checked by just echo $PATH on your command line. You may just add something to that by using export PATH=/usr/local/php5:$PATH or similar. You can add that line to the ~/.bash_profile file as well to store that for any later use.

fdomig
  • 4,417
  • 3
  • 26
  • 39
  • Thanks for the answer. I needed to add /usr/local/php5 to my PATH so I put it in my .bash_profile I then ran the sudo mv ... command If I now run php -v from terminal I get -bash: /usr/bin/php: is a directory If I look at phpinfo on localhost It shows it running 5.4.5 – ianckc Aug 11 '12 at 10:56
  • I am sorry, you have to link to the real php 5.4 binary which is somewhere below `/usr/local/php5` probably `/usr/local/php5/bin/php` or similar. – fdomig Aug 11 '12 at 11:00