一、安装(可以用 brew 安装)
sudo brew install nginx
如果报下面这个错误的话
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
运行
sudo chown -R $(whoami) /usr/local或者
sudo chown -R $(whoami) /usr/local/Cellar
//系统版本不同可能会有一个生效,我用的第二个
然后运行
brew install nginx
二、查看 nginx 版本
nginx -v
三、启动 nginx
sudo nginx
四、查看 nginx 是否启动成功
在浏览器中访问 http://localhost:8080,如果出现如下界面,则说明启动成功.
五、关闭nginx
sudo nginx -s stop
六、重新加载nginx
sudo nginx -s reload