I feel this is an awfully obtuse question to ask, but strangely, this problem is poorly documented.
I would like to upgrade PHP, but there are several problems:
You can use curl to update php version.
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.3
Last Step:
export PATH=/usr/local/php5/bin:$PATH
Check the upgraded version
php -v
best way to upgrade is compile it from source
see this tutorial that may be helful for you
http://www.computersnyou.com/2012/09/how-to-upgrade-php-in-mac-osx-compiling.html
Upgrading to Snow Leopard won't solve the your primary problem of keeping PHP up to date. Apple doesn't always keep the third party software that it bundles up to date with OS updates. And relying on Apple to get you the bug fix / security update you need is asking for trouble.
Additionally, I would recommend installing through MacPorts (and doing the config necessary to use it instead of Apple's PHP) rather than try to upgrade the Apple supplied PHP in place. Anything you do to /usr/bin
risks being overwritten by some future Apple update.
There is no built-in package manager. MacPorts doesn't recognize php as an installed package because it didn't install PHP itself.
You could still install it with MacPorts. sudo port install php52
(or whichever version you want) will install PHP.
It won't overwrite the Apple-supplied version. It'll install it under /opt/local
. You can add /opt/local
to the beginning of your $PATH
, and use the MacPorts version in your Apache config.
I use this: https://github.com/Homebrew/homebrew-php
The command is:
$ xcode-select --install
$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
$ brew options php56
$ brew install php56
Then config in your .bash_profile
or .bashrc
# Homebrew PHP CLI
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
Option #1
As recommended here, this site provides a convenient, up-to-date one liner.
This doesn't overwrite the base version of PHP on your system, but instead installs it cleanly in /usr/local/php5.
Option #2
My preferred method is to just install via Homebrew.