SierraにHomebrewでMySQL, Apache,PHPをインストール

Homebrew自体の準備

brew update
brew doctor

MySQL

brew install mysql
mysql_secure_installation
mysql.server start
//loginで開始するように設定
brew services start mysql

Apache

brew tap homebrew/dupes
brew tap homebrew/apache
//デフォルト8080で動作
brew install httpd24
//loginで開始するように設定
brew services start homebrew/apache/httpd24

PHP

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
//既存のPHPがあれば
brew unlink php55
//httpd.confに php7_module の行を追加
brew install php71 --with-httpd24

Apacheの設定
/usr/local/etc/apache2/2.4/httpd.conf

//設定済のはず
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
//修正する
ServerName localhost:8080
//index.phpを書き加える
DirectoryIndex index.php index.html
//コメント解除
Include /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf
LoadModule rewrite_module libexec/mod_rewrite.so
//末尾に追加
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>

vhostの設定
/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf

<VirtualHost *:8080>
    ServerName localhost
    DocumentRoot "/usr/local/var/www/htdocs"
    <Directory "/usr/local/var/www/htdocs">
        AllowOverride All
        Require all granted
    </Directory>
    CustomLog "/usr/local/var/log/apache2/localhost.access.log" common 
    ErrorLog "/usr/local/var/log/apache2/localhost.error.log"
</VirtualHost>
 
<VirtualHost *:8080>
    ServerName SSS.dev
    DocumentRoot "XXX/public"
    <Directory "XXX/public">
        AllowOverride All
        Require all granted
    </Directory>
    CustomLog "/usr/local/var/log/apache2/SSS.dev.access.log" common 
    ErrorLog "/usr/local/var/log/apache2/SSS.dev.error.log"
</VirtualHost>

PHPの設定
/usr/local/etc/php/7.1/php.ini

date.timezone = Asia/Tokyo
default_charset = "UTF-8"
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII

その他、PHP開発用

brew install php71-xdebug