Skip to content

Instantly share code, notes, and snippets.

@minhd
Last active July 20, 2018 00:16
Show Gist options
  • Save minhd/550efb9a137c052e13c0ea2a498f5c5d to your computer and use it in GitHub Desktop.
Save minhd/550efb9a137c052e13c0ea2a498f5c5d to your computer and use it in GitHub Desktop.
Install PHP on MacOS Sierra

Use Homebrew/core instead of Homebrew/php

brew install php@5.6 --with-pear
brew install php@7.0 --with-pear
brew install php@7.1 --with-pear
brew install php@7.2 --with-pear

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.6/php.ini
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini
/usr/local/etc/php/7.2/php.ini

To switch to PHP 5.6

brew unlink php@7.2 && brew link --force --overwrite php@5.6

To check which php.ini is in used

php --ini

or

php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

Check for xdebug

php -i | grep xdebug

for php 7.0

pecl install xdebug

for php 5.6

pecl install xdebug-2.5.0

Modify

# /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini

[xdebug]
zend_extension="/usr/local/Cellar/php@5.6/5.6.36_1/pecl/20131226/xdebug.so"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment