Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I upgrade PHP in Mac OS X?

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:

  • There is no built-in package manager. MacPorts doesn't recognize php as an installed package because it didn't install PHP itself.
  • Running locate php indicates there are probably many dependencies.
  • I don't know HOW php was installed, as it was included with the OS, so I don't know whether I should install from source or download binaries. I also don't know the proper way to uninstall the previous version without breaking dependencies.

I am running on Leopard. I have a feeling Apple doesn't want you to upgrade. Would buying Snow Leopard and upgrade solve this problem (and future ones like it)?

like image 763
thebossman Avatar asked Mar 26 '10 19:03

thebossman


People also ask

How do I update my PHP version on Mac?

To update the PHP version, update the brew using the command brew update . Then, use the command brew upgrade php . It upgrades the current version to the latest version of PHP. Then, restart the webserver to see the changes.


2 Answers

You may want to check out Marc Liyanage's PHP package. It comes in a nice Mac OS X installer package that you can double-click. He keeps it pretty up to date.

http://php-osx.liip.ch/

Also, although upgrading to Snow Leopard won't help you do PHP updates in the future, it will probably give you a newer version of PHP. I'm running OS X 10.6.2 and it has PHP 5.3.0.

like image 172
Scott Saunders Avatar answered Oct 09 '22 22:10

Scott Saunders


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" 
like image 35
ethanxm Avatar answered Oct 09 '22 23:10

ethanxm