Installing PHP 5.5 and MySQL on Mac OSX

Yosemite comes preinstalled with Apache and PHP, we want to use Homebrew to install PHP to ensure we can get the latest updates by running a simple command, brew update.

First off, we need to install Homebrew. You can follow the latest installation online via their website which I would recommend but for the sake of being lazy, I’ve pasted it below. Please remember this command correct as from the date of this post:

After we’ve installed Homebrew, we want to go ahead and use it! Simple run these commands to install PHP 5.5:

That’s the easy part, Homebrew does most of the work for you. If you’ve every tried to install anything from source, you’ll know what I’m talking about.

Finally, to get you set up, there’s a few configuration tweaks to sort out. As mentioned above, Yosemite comes preinstalled with Apache and PHP but we want to use Homebrew’s version.

There are instructions that are displayed after the installation from Homebrew which you can always get back by running brew info php55 but I’ll spell out the important parts for you.

To get Apache (which is preinstalled) to use Homebrew’s version of PHP, simply edit your httpd.conf file:

Find and replace the line loading the module:

Always remember to restart Apache when changing any configuration files:

Leave a Reply

Your email address will not be published. Required fields are marked *