Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save khoand0000/43388af2d1c88e4e4f7b to your computer and use it in GitHub Desktop.
Save khoand0000/43388af2d1c88e4e4f7b to your computer and use it in GitHub Desktop.
install php7, pear, mysql, PHP_CodeSniffer by homebrew

Install php7 with pear

$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
$ brew install php70 --with-pear

Enable php7 with apache2

$ 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>

Restart apache2

$ sudo apachectl restart

Install PHP_CodeSniffer

$ pear install PHP_CodeSniffer

Run phpcs

# $ /usr/local/Cellar/php70/7.0.2/bin/phpcs
$ $(brew --prefix homebrew/php/php70)/bin/phpcs

Install Mysql

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment