Things I had to do using Homebrew to get my local web dev environment back up and running after migration to OSX Sierra + Xcode 8.1.
Note: I used brew reinstall because I had already installed most of this previously under Yosemite. Probably better ways to do this, but this is what worked for me.
brew doctor
brew update
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew install httpd
Check for errors.
tail -f /usr/local/var/log/apache2/error_log
Useful commands.
sudo apachectl start
sudo apachectl stop
sudo apachectl -k restart
Modify /usr/local/etc/httpd/httpd.conf and test Apache.
DocumentRoot "/Users/deloo"
<Directory "/Users/deloo">
AllowOverride All
Uncomment rewrite_module
User deloo
Group staff
<If Module dir_module>
DirectoryIndex index.php index.html
</IfModule>
ServerName localhost
sudo apachectl -k restart
brew reinstall php56 --with-httpd
brew reinstall php56-opcache php56-apcu php56-mcrypt php56-imagick php56-pdo-dblib php56-yaml php56-xdebug --build-from-source
brew unlink php56
brew prune
brew reinstall php70 --with-httpd
brew reinstall php70-opcache php70-apcu php70-mcrypt php70-imagick php70-pdo-dblib php70-yaml php70-xdebug --build-from-source
brew unlink php70
brew prune
In my case php71 ended up needing special attention before re-install.
brew uninstall --force php71
brew cleanup --force -s php71
brew prune
sudo rm -fr /usr/local/opt/php71
brew reinstall php71 --with-httpd
brew reinstall php71-opcache php71-apcu php71-mcrypt php71-imagick php71-pdo-dblib php71-yaml php71-xdebug --build-from-source
brew unlink php71
brew prune
Back to PHP5
brew link php56
PHP ini paths
/usr/local/etc/php/5.6/php.ini
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini
In /usr/local/etc/httpd/httpd.conf modify the paths as follows:
LoadModule php5_module /usr/local/Cellar/php56/5.6.31_7/libexec/apache2/libphp5.so
#LoadModule php7_module /usr/local/Cellar/php70/7.0.23_15/libexec/apache2/libphp7.so
#LoadModule php7_module /usr/local/Cellar/php71/7.1.8_20/libexec/apache2/libphp7.so
We can only have one module processing PHP at a time, so for now, comment out all but the php56 entry:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
#LoadModule php7_module /usr/local/opt/php70/libexec/apache2/libphp7.so
#LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
Verify php install one more time.
curl -L https://gist.github.com/w00fz/142b6b19750ea6979137b963df959d11/raw > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp
Add LoadModule for sphp switcher to httpd.conf (final PHP change)
LoadModule php5_module /usr/local/lib/libphp5.so
#LoadModule php7_module /usr/local/lib/libphp7.so
It's IMPORTANT at this stage to fully stop your Apache sever, and start it again. Do not just restart it!
sudo apachectl -k stop
sudo apachectl start
I had some error messages regarding php*-intl, this fixed it. Had to be run for each version of php as do any other updates.
sphp71
brew reinstall --build-from-source php71-intl
brew update
brew upgrade
sphp56
brew reinstall --build-from-source php56-intl
brew update
brew upgrade
sphp70
brew reinstall --build-from-source php70-intl
brew update
brew upgrade
Apache already comes preconfigured to support this behavior but it is not enabled.
First you will need to uncomment the following lines in your /usr/local/etc/httpd/httpd.conf file:
LoadModule vhost_alias_module libexec/mod_vhost_alias.so
and:
# Virtual hosts
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
Edit /usr/local/etc/httpd/extra/httpd-vhosts.conf :
<VirtualHost *:80>
DocumentRoot "~/Sites/active-projects"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "~/Sites/active-projects/myproject.dev"
ServerName myproject.dev
</VirtualHost>
openssl genrsa -des3 -passout pass:x -out local.dev.pass.key 2048
openssl rsa -passin pass:x -in local.dev.pass.key -out local.dev.key
rm local.dev.pass.key
openssl req -new -key local.dev.key -out local.dev.csr
openssl x509 -req -days 365 -in local.dev.csr -signkey local.dev.key -out local.dev.crt
-
Open the Terminal
-
Use
mysqldumpto backup your databases -
Check for MySQL processes with:
ps -ax | grep mysql -
Stop and kill any MySQL processes
-
Analyze MySQL on HomeBrew:
brew remove mysql brew cleanup -
Remove files:
sudo rm /usr/local/mysql sudo rm -rf /usr/local/var/mysql sudo rm -rf /usr/local/mysql* sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/My* -
Unload previous MySQL Auto-Login:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist -
Remove previous MySQL Configuration:
subl /etc/hostconfig` # Remove the line MYSQLCOM=-YES- -
Remove previous MySQL Preferences:
rm -rf ~/Library/PreferencePanes/My* sudo rm -rf /Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm -rf /private/var/db/receipts/*mysql* -
Restart your computer just to ensure any MySQL processes are killed
-
Try to run mysql, it shouldn't work
brew install mysql
brew services start mysql