$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
$ brew install php70 --with-pear
$ sudo nano /etc/apache2/httpd.conf
Type Ctrl+W: php
#Comment out the PHP5 module
#LoadModule php5_module libexec/apache2/libphp5.so
#Enable PHP 7 module
LoadModule php7_module /usr/local/opt/php70/libexec/apache2/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
$ sudo apachectl restart
$ pear install PHP_CodeSniffer
Run phpcs
# $ /usr/local/Cellar/php70/7.0.2/bin/phpcs
$ $(brew --prefix homebrew/php/php70)/bin/phpcs
If you have a old mysql (from brew), uninstall it first and remove data folder also to make sure your machine is clean
$ brew uninstall mysql
$ rm -rf /usr/local/var/mysql
Install mysql
$ brew install mysql
I don't know why, but mysql doesn't have any rows (no users) in mysql.user
table. So I need to add root
user by commands:
$ mysql.server stop
$ mysql.server start --skip-grant-tables --skip-networking
$ mysql
MYSQL> show create user 'root'@'localhost'\G
MYSQL> show grants for 'root'@'localhost';
MYSQL> UPDATE mysql.user SET authentication_string = PASSWORD('khoakhung'), password_expired = 'N' WHERE User = 'root' AND Host = 'localhost';
MYSQL> FLUSH PRIVILEGES;
MYSQL> quit
If you get a error The last packet sent successfully to the server was 0 milliseconds ago
. Try the solution http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql, mine is that used --skip-networking
when starting mysql
References:
- http://w3bsmart.blogspot.com/2015/08/installing-php-7-on-os-x-yosemite.html
- http://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-osx-10-11-el-capitan/
- http://dev.mysql.com/doc/refman/5.7/en/adding-users.html
- http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
- https://robots.thoughtbot.com/starting-and-stopping-background-services-with-homebrew
- http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql