Saturday, February 08, 2014

Upgrade PHP with homebrew on OS X

I am new to homebrew, whatever I shows here is just my experience with homebrew, might not be the best practise.

Homebrew is similar with Fink and MacPorts, is just a software management tools to install third party software, especially open source software on Mac OS X. It install the software into /usr/local directory, which will not replace your system software.

Update to the latest system if possible. Later system may have a better support, homebrew just download the binary if it is available on your system. Which save you time. I use homebrew on my older system, it download and compile the software, I encounter error and retry and retry...

These are the steps to update php with brew, I refer the steps from the internet:

$ rm -rf ~/.pearrc # remove existing PHP/PEAR config files
$ brew update
$ brew upgrade
$ brew tap homebrew/dupes
$ brew tap josegonzalez/homebrew-php
$ brew install freetype jpeg libpng gd zlib openssl unixodbc

$ brew install php55 # or php53

It takes a few minutes if binary is available.
I experience some issues on my OS X 10.6.2 with 32 bits CPU. I have php 5.3.1 on my system, but the PHP composer need 5.3.2 or above.


Issues with freetype

$ brew install freetype
builds/unix/ftsystem.c:246: error: 'Cannot_Open_Resource' undeclared (first use in this function)
builds/unix/ftsystem.c:369: error: 'Cannot_Open_Stream' undeclared (first use in this function)

Manual compile freetype works! From http://www.freetype.org/download.html. I compile freetype-2.5.2:

$ cd freetype-2.5.2
$ ./configure
$ make
$ sudo make install

$ brew install php53 --ignore-dependencies freetype --without-apache

Please take note, the php I installed doesn't works with Apache web server. Finally I have my PHP 5.3.28.

$ php -v
PHP 5.3.28 (cli) (built: Jan 22 2014 18:27:26)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

No comments:

Post a Comment