OS X PHP Dev Env Setup
更新日期:
OS: OS X El Capitan Version 10.11.4
-
Install Homebrew
1/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -
Install PHP 5.6
123brew install --without-apache --with-fpm --with-mysql php56# if an error occured as: No available formula for php56, execute the following command at first.brew tap homebrew/homebrew-phpThe configuration file of PHP is located at
/usr/local/etc/php/5.6/php.ini
. The configuration file of PHP-FPM is located at/usr/local/etc/php/5.6/php-fpm.conf
. To install PHP extensions, typebrew install php56-memcached
for example. It will be put under directory/usr/local/etc/php/5.6/conf.d
after installation. -
Update $PATH env variable in your
~/.bashrc
or~/.zshrc
1export PATH="/usr/local/sbin:/usr/local/bin:$PATH" -
Start PHP-FPM
12ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgentslaunchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist -
Add a script to restart fpm Create a new file named /usr/local/etc/php/fpm-restart
123chmod ug+x /usr/local/etc/php/fpm-restartcd /usr/local/sbin/ln -s /usr/local/etc/php/fpm-restart -
Install Nginx
1brew install nginxThe configuration file of Nginx is located at
/usr/local/etc/nginx/nginx.conf
. To reload Nginx configuration, trynginx -s reload
The default server root located as:/usr/local/opt/nginx/html