Install PHP with PNG Support on Apache in Yosemite

Yosemite comes with Apache + PHP out of the box, but its PHP binary is a bit handicapped. It doesn’t come with built in PNG support.

This causes issues if you are developing WordPress sites: resizing PNG images will silently fail. If you have custom image sizes set in your WordPress theme, they will not be created at all if PHP is not compiled with PNG support.

Here’s how to recompile PHP on Yosemite via Brew:

brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php brew install freetype jpeg libpng gd brew install php56

You’ll have to edit your Apache configuration to use the new PHP installation:

nano /etc/apache2/httpd.conf # add the following line to the above file LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so # then save, exit nano, and run this command sudo apachectl restart

There are also some additional WordPress & PHP tools you can install via brew.

Continue Reading