Hasan Setiawan

Write, write, write give your wings on code!

Follow me on GitHub

Installing PHP on Mac

You can get a full list of available options to include by typing brew options php55, for example. In this example we are just including Apache support via --with-httpd24 to build the required PHP modules for Apache.

Run the command bellow to install PHP in your Mac


$ brew install php55 --with-httpd24
$ brew unlink php55
$ brew install php56 --with-httpd24
$ brew unlink php56
$ brew install php70 --with-httpd24
$ brew unlink php70
$ brew install php71 --with-httpd24
        

This may take some time as your computer is actually compiling PHP from source.

You must reinstall each PHP version with reinstall command rather than install if you have previously installed PHP through Brew.

Also, you may have the need to tweak configuration settings of PHP to your needs. A common thing to change is the memory setting, or the date.timezone configuration. The php.ini files for each version of PHP are located in the following directories:

            
/usr/local/etc/php/5.5/php.ini
/usr/local/etc/php/5.6/php.ini
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini