新版的 Mac OS 內置了Apache 和 PHP,能夠經過如下命令查看Apache和PHP的版本號:php
# httpd -v
# php -v
Mac下的Homebrew至關於Linux下的apt-get、yum,能夠得到最新版的各類安裝包。mysql
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝完成後,運行如下命令檢查是否安裝成功nginx
brew doctor
更新、升級下brew源git
brew update && brew upgrade
brew install nginx
修改配置文件github
sudo vim /usr/local/etc/nginx/nginx.conf #修改默認的8080端口爲80
設置自啓sql
sudo cp -v /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
啓動nginx服務vim
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
如今默認監聽80端口,運行如下命令測試ruby
curl -IL http://127.0.0.1:80
查看nginx幫助php7
nginx -h
中止Nginx服務curl
sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
經過 brew 安裝不一樣版本的php
# brew tap homebrew/dupes # brew tap homebrew/php
# brew tap josegonzalez/homebrew-php
安裝PHP7
# brew install php70 --with-fpm --with-mysql
設置自啓
sudo cp -v /usr/local/opt/nginx/homebrew.mxcl.php70.plist /Library/LaunchDaemons/
啓動php服務
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.php70.plist