To do so, we are going to get most of the stuff from Jose Gozalez’s formulae. You will need a copy of homebrew installed, you can read about how to install homebrew here.

Let’s start by setting up the dependencies in homebrew.

[code language=“bash”]brew tap homebrew/dupes

brew tap josegonzalez/homebrew-php[/code]

Now php54 is available for install through:

[code language=“bash”]brew install php54 –with-mysql[/code]

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php5_module /usr/local/Cellar/php54/5.4.5/libexec/apache2/libphp5.so

The php.ini file can be found in:

/usr/local/etc/php/5.4/php.ini

If pear complains about permissions, ‘Fix’ the default PEAR permissions and config:

[code language=“bash”] chmod -R ug+w /usr/local/Cellar/php54/5.4.5/lib/php

pear config-set php_ini /usr/local/etc/php/5.4/php.ini

[/code]

After you enabled PHP in Apache, make sure you restart Apache too!

[code language=“bash”]sudo apachectl restart[/code]

Troubleshooting

If you get an error that looks like this:”

[code language=“bash”]configure: error: freetype.h not found.

Error: uncaught throw `Failed executing: ./configure –prefix=/usr/local/Cellar/php54/5.4.5 –disable-debug –localstatedir=/usr/local/var –sysconfdir=/usr/local/etc/php/5.4 –with-config-file-path=/usr/local/etc/php/5.4 –with-config-file-scan-dir=/usr/local/etc/php/5.4/conf.d –with-iconv-dir=/usr –enable-dba –with-ndbm=/usr –enable-exif –enable-soap –enable-sqlite-utf8 –enable-wddx –enable-ftp –enable-sockets –enable-zip –enable-pcntl –enable-shmop –enable-sysvsem –enable-sysvshm –enable-sysvmsg –enable-mbstring –enable-mbregex –enable-zend-signals –enable-dtrace –enable-bcmath –enable-calendar –with-zlib=/usr/local/Cellar/zlib/1.2.7 –with-bz2=/usr –with-ldap –with-ldap-sasl=/usr –with-xmlrpc –with-kerberos=/usr –with-libxml-dir=/usr/local/Cellar/libxml2/2.8.0 –with-xsl=/usr –with-curl=/usr –with-gd –enable-gd-native-ttf –with-freetype-dir=/usr/X11 –with-mcrypt=/usr/local/Cellar/mcrypt/2.5.8 –with-jpeg-dir=/usr/local/Cellar/jpeg/8d –with-png-dir=/usr/X11 –with-gettext=/usr/lo[/code]

It is because your freetype is not working right. It happened to me after I upgraded from Mac OS X Lion to Mac OS X Mountain Lion. To do safe, uninstall and install freetype back:

[code language=“bash”]brew uninstall freetype

brew install freetype[/code]

Also if you get a permissions error, you might have to fix it:

[code language=“bash”]➜ ~ brew install php54

==> Downloading http://www.php.net/get/php-5.4.5.tar.bz2/from/this/mirror

Already downloaded: /Library/Caches/Homebrew/php54-5.4.5

==> ./configure –prefix=/usr/local/Cellar/php54/5.4.5 –disable-debug –localstatedir=/usr/local/var –sysconfdir=/usr/local/etc/php/5.4 –with-config-file-path

==> make

==> make install

==> /usr/local/Cellar/php54/5.4.5/bin/pear config-set php_ini /usr/local/etc/php/5.4/php.ini

no write access to /Users/kahwee/.pearrc!

Error: uncaught throw `Failed executing: /usr/local/Cellar/php54/5.4.5/bin/pear config-set php_ini /usr/local/etc/php/5.4/php.ini’[/code]

I changed the owner from root to kahwee (my username):

[code language=“bash”]sudo chown kahwee /Users/kahwee/.pearrc[/code]

That’s all, hope it helps!

comments powered by Disqus