1. 查看是否存在 nginx
 
执行brew search nginx 命令查询要安装的软件是否存在
brew search nginx
2. 安装nginx
brew install nginx
3. 查看版本
nginx -v
4. 查看信息
查看ngxin下载的位置以及nginx配置文件存放路径等信息
brew info nginx- 下载的存放路径

/usr/local/Cellar/nginx/1.27.0- 配置文件存放路径

/usr/local/etc/nginx/nginx.conf- 网站根目录
 
 
/usr/local/var/www5. 确认存放路径


6. 启动
在终端cd /usr/local/Cellar/nginx/1.27.0/bin进入bin目录,然后执行nginx命令(没有报错就是启动成功) 
cd /usr/local/Cellar/nginx/1.27.0/bin 
默认端口 8080
打开浏览器输入 localhost:8080
默认的网站根目录为html(即/usr/local/var/www),而默认的索引文件为index.html 和 index.htm
7. 关闭
nginx -s stop8. 修改端口
/usr/local/etc/nginx/nginx.conf
修改之后重新运行nginx -s reload命令就能打开自定义的端口号 
进入
cd /usr/local/Cellar/nginx/1.27.0/binnginx -s reload各种命令
brew services start nginx    # 启动
nginx -c /usr/local/nginx/conf/nginx.conf    # 首先利用配置文件启动nginx
brew services stop nginx     # 停止
service nginx restart        # 重启
nginx -h                     # 查看帮助信息
nginx -v                     # 查看nginx版本(小写字母v)
nginx -V                     # 除版本信息外还显示配置参数信息(大写字母V)
start nginx                  # 启动nginx
start nginx -c filename      # 指定配置文件启动nginx
nginx -s quit                # 关闭nginx,完整有序的停止nginx,保存相关信息
nginx -s stop                # 关闭nginx,快速停止nginx,可能并不保存相关信息
nginx -s reload              # 重新载入nginx,当配置信息修改需要重新加载配置是使用
nginx -s reopen              # 重新打开日志文件
nginx -t -c filename         # 测试nginx配置文件是否正确
systemctl stop nginx.service       # linux停止
systemctl start nginx.service      # linux启动
ps aux | grep nginx                # 查看服务
systemctl restart nginx.service    # 重启
netstat -tlnp                      # 端口号