Install Apache PHP and MySQL on macOS Sierra

Note:This is for fresh installations. Refer https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions for more details

  • /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
  • brew tap homebrew/homebrew-php
  • brew tap homebrew/dupes
  • brew tap homebrew/versions
  • brew tap homebrew/php
  • sudo apachectl stop
  • sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
  • brew install httpd24 –with-privileged-ports –with-http2
  • brew install homebrew/apache/httpd24 –with-privileged-ports –with-http2
  • sudo cp -v /usr/local/Cellar/httpd24/2.4.25/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons
  • sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
  • sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
  • sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
  • brew install php71 –with-httpd24
  • sudo nano /usr/local/etc/apache2/2.4/httpd.conf
    • <FilesMatch \.php$>
    • SetHandler application/x-httpd-php
    • </FilesMatch>
  • brew services start homebrew/php/php71
  • sudo apachectl -k restart
  • nano info.php

Download DMG file from MySQL website and install.  After installation, start MySQL from System Preferences > MySQL. Then run these commands

  • export PATH=/usr/local/mysql/bin:$PATH
  • mysql_secure_installation

This DMG does not have MySQL Workbench. Download and install separately from MYSQL website.

Posted in php
error: Uh oh ...