PHP on Mavericks with homebrew

We are gonna use homebrew to install PHP in our MacOSx Mavericks, to accomplished this goal we are gonna use the following tap from @josegonzalez

On the link above you´ll find a full and detailed instructions to install PHP in different versions of MacOSx, we are going to resume how to install PHP on Mavericks

First of all we have to install xcode-command-line with the following command:

xcode-select --install

If we see the error below you have to download and install the xcode-command-line from Apple Developer Site

Can't install the software because it is not currently available from the Software Update server.

Once the xcode-command-line are installed we can go on installing PHP using homebrew

We assume that you already have homebrew installed in your machine

Now we have to install the dependence which will have problems with using the following command:

brew install libpng

We are going to see some errors saying that the are problem linking the library because you don´t have right in some path, something like that:

Warning: You have unlinked kegs in your Cellar Leaving kegs  unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these:

That´s because Mavericks have diferent rights that other version, so we are gonna change that rights only to install our software and then rollback to the original rights.


That´s are the folders to which we must apply the permission change. And this is how we have to apply that changes.

sudo chown YOURUSER:wheel /usr/local/include
sudo chown YOURUSER:wheel /usr/local/lib
sudo chown YOURUSER:wheel /usr/local/lib/pkgconfig

Remember to rollback the default user:group to this folders root:wheel

After all this we are gonna be able to run our normal hombrew command that will allow us to install PHPin our system.

brew install php55

After a while waiting for download the packages, make and install, here we go, last PHP version on our Mavericks.

There are a few cool tips on the imagen above

Just one last step make sure that we have the correct version of PHP linked to our command line, you should update the $PATH variable in either your .bashrc or .bash_profile:

# Swapping to PHP55
export PATH="$(brew --prefix josegonzalez/php/php55)/bin:$PATH"
export PATH="$(brew --prefix php55)/bin:$PATH"

We can check our PHP version installed with the following command:

php --version

And to check our PEAR and the PHP linked to it, run the following command:

pear version