Apache and PHP on OSX Setup Notes
Links
Here's the link I followed to set this up: https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions
Here's another good link:
https://gist.github.com/DragonBe/0faebe58deced34744953e3bf6afbec7
Apache
On my local macbook, first make sure the default installation of apache is not running:
sudo apachectl stop
FYI: I think the default php installation is here:
/private/etc/apache2
Then, I installed http
from homebrew
brew install httpd
Here's how to set up the service (not sure exactly what this does):
sudo brew services start httpd
After running that, I can use this to control apache:
sudo apachectl -k restart sudo apachectl stop
Watch the logs like so:
tail -f /usr/local/var/log/httpd/error_log
Configuration is found here:
/usr/local/etc/httpd/httpd.conf
Apache VHost
I configured the vhost fordev.dryaddesigncompany.com
. Don't forgetto add a line to hosts file as well.PHP
I already had php installed on macbook, hopefully it'll work:
php --version PHP 5.6.30
By default, php is under /usr/bin/php
. After using brew to install and configure, the binary to use is /usr/local/bin/php
Here's how I installed via homebrew:
brew tap homebrew/homebrew-php brew install php56 --with-httpd
Installed into:
/usr/local/Cellar/php56/5.6.32_8
It can be configured via:
/usr/local/etc/php/5.6/php.ini
Next, install v70:
brew unlink php56 brew install php70 --with-httpd brew unlink php70
Installed 70 here:
/usr/local/Cellar/php70/7.0.25_17
I haven't installed these yet:
brew install php71 --with-httpd brew unlink php71 brew install php72 --with-httpd
Here's a trick to make sure we're using the php56:
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
To switch back and forth between php versions:
brew unlink php72 brew link php56