安装nginx之前要安装Homebrew,参考链接https://www.cnblogs.com/wxhou/p/14174468.html
用brew很方便地安装nginx,安装命令:
sudo chown -R $(whoami) /usr/local/Homebrew
brew install nginx
启动nginx服务
brew services start nginx
利用
http://localhost:8080
进行访问, 如果出现如下界面,说明启动成功.
另外几个比较方便的指令
重启nginx服务
brew services restart nginx
关闭nginx服务
brew services stop nginx
查看nginx版本
nginx -v
重新加载nginx
nginx -s reload
停止nginx
nginx -s stop
在终端输出的信息里看到一些配置路径:
/usr/local/etc/nginx/nginx.conf (配置文件路径)
/usr/local/var/www (服务器默认路径)
/usr/local/Cellar/nginx/1.12.4 (安装路径)(具体参照自己安装的版本)