MAC上安装Homebrew、Nginx、PHP、MySQL
准备工作
新版的 Mac OS 内置了Apache 和 PHP,可以通过以下命令查看Apache和PHP的版本号:
# httpd -v
# php -v
安装Homebrew
Mac下的Homebrew相当于Linux下的apt-get、yum,可以获得最新版的各种安装包。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装完成后,运行以下命令检查是否安装成功
brew doctor
更新、升级下brew源
brew update && brew upgrade
安装Nginx
brew install nginx
修改配置文件
sudo vim /usr/local/etc/nginx/nginx.conf #修改默认的8080端口为80
设置自启
sudo cp -v /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
启动nginx服务
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
现在默认监听80端口,运行以下命令测试
curl -IL http://127.0.0.1:80
查看nginx帮助
nginx -h
停止Nginx服务
sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
安装PHP
通过 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
安装MySQL