Mac 通过 Homebrew 安装 nginx 并设置开机启动配置_Nick的博客-CSDN博客

Mac 通过 Homebrew 安装 nginx 并设置开机启动配置

步骤如下:

brew install nginx

通过 Homebrew 下载的软件默认位置在 /usr/local/Cellar

nginx -h 查看 nginx 命令参数
nginx -s reopen | quit | reload | stop 开启 退出 重启 停止
nginx -t 测试配置文件是否正确

mkdir -p ~/Library/LaunchAgents //[可选]先查看此目录是否存在,不存在执行此命令新建

cp /usr/local/Cellar/nginx/ nginx版本 /homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

sudo chown root:wheel /usr/local/Cellar/nginx/ nginx版本 /bin/nginx

sudo chmod u+s /usr/local/Cellar/nginx/ nginx版本 /bin/nginx

补充:如果执行 nginx -s reload 重启服务器报以下错误信息

nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)

执行以下命令即可

nginx -c /usr/local/etc/nginx/nginx.conf

原网址: 访问
创建于: 2021-06-20 12:19:14
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论