macOS安装nginx出错

问题

错误内容:

1
2
3
4
5
6
7
8
9
10
brew install nginx
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1j.big_sur.bottle.tar.gz
#=#=#
curl: (22) The requested URL returned error: 404
Trying a mirror...
==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1j.big_sur.bottle.tar.gz
#=#=-# #
curl: (22) The requested URL returned error: 403 Forbidden
Error: Failed to download resource "openssl@1.1"
Download failed: https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1j.big_sur.bottle.tar.gz

原因&解决

之前brew使用的教育源。教育源无法找到openssl资源导致无法安装nginx

更换至阿里云的源,问题解决。

1
2
3
4
5
6
7
8
9
10
# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 刷新源
brew update

Nginx 常用指令

nginx -V 查看版本以及配置文件地址

nginx -v 查看版本

nginx -c filename 指定配置文件

nginx -h 帮助