问题
使用 homebrew 安装Nginx出现以下错误:
AntonyZhang:~ zwq$ brew install nginx
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/pcre-8.45.mojave.bottle.tar.gz
==> Downloading from https://homebrew.bintray.com/bottles/pcre-8.45.mojave.bottle.tar.gz
curl: (22) The requested URL returned error: 403 Forbidden
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/manifests/8.45
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/blobs/sha256:a42b79956773d18c4ac337868cfc15fadadf5e779d65c12ffd6f8fd379b5514
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:a42b79956773d18c4ac337868cfc15fadadf5e779d65c
######################################################################## 100.0%
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/nginx-1.21.1.mojave.bottle.tar.gz
==> Downloading from https://homebrew.bintray.com/bottles/nginx-1.21.1.mojave.bottle.tar.gz
curl: (22) The requested URL returned error: 403 Forbidden
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/nginx/manifests/1.21.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nginx/blobs/sha256:51c2b45dce74a294f53a04eb51be7e1aa63101b72018bb38648b5161e6b8d0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:51c2b45dce74a294f53a04eb51be7e1aa63101b72018b
######################################################################## 100.0%
==> Installing dependencies for nginx: pcre
==> Installing nginx dependency: pcre
==> Pouring pcre-8.45.mojave.bottle.tar.gz
tar: Error opening archive: Failed to open '/Users/zwq/Library/Caches/Homebrew/downloads/990bc2c88435d66a1dd78451b41fd73dbade409d5a615c90d2640ccd2479e3a8--pcre-8.45.mojave.bottle.tar.gz'
Error: Failure while executing; `tar --extract --no-same-owner --file /Users/zwq/Library/Caches/Homebrew/downloads/990bc2c88435d66a1dd78451b41fd73dbade409d5a615c90d2640ccd2479e3a8--pcre-8.45.mojave.bottle.tar.gz --directory /private/tmp/d20210815-23893-1tv8c6g` exited with 1. Here's the output:
tar: Error opening archive: Failed to open '/Users/zwq/Library/Caches/Homebrew/downloads/990bc2c88435d66a1dd78451b41fd73dbade409d5a615c90d2640ccd2479e3a8--pcre-8.45.mojave.bottle.tar.gz'
原因:
pcre没有安装成功,需要手动先安装这个前置依赖
解决方案
1. 先安装pcre
AntonyZhang:~ zwq$ brew install pcre
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/pcre-8.45.mojave.bottle.tar.gz
==> Downloading from https://homebrew.bintray.com/bottles/pcre-8.45.mojave.bottle.tar.gz
curl: (22) The requested URL returned error: 403 Forbidden
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/manifests/8.45
Already downloaded: /Users/zwq/Library/Caches/Homebrew/downloads/4a3bba0e8d1899c13ac3442d2c49df6c1999948bdc0943f2f179693257d82545--pcre-8.45.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/blobs/sha256:a42b79956773d18c4ac337868cfc15fadadf5e779d65c12ffd6f8fd379b5514
Already downloaded: /Users/zwq/Library/Caches/Homebrew/downloads/456b31dd91116840800d9cc2f35c6f2ebde8cfe8513e6d08dd6974f3309dc4f9--pcre--8.45.mojave.bottle.tar.gz
==> Pouring pcre--8.45.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/pcre/8.45: 204 files, 5.5MB
2. 再次重新安装Nginx
AntonyZhang:~ zwq$ brew install nginx
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/nginx-1.21.1.mojave.bottle.tar.gz
==> Downloading from https://homebrew.bintray.com/bottles/nginx-1.21.1.mojave.bottle.tar.gz
curl: (22) The requested URL returned error: 403 Forbidden
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/nginx/manifests/1.21.1
Already downloaded: /Users/zwq/Library/Caches/Homebrew/downloads/4d8faa3c372bac248958100a83a897c816954e5082dbc1c58825b6015f50cb62--nginx-1.21.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/nginx/blobs/sha256:51c2b45dce74a294f53a04eb51be7e1aa63101b72018bb38648b5161e6b8d0
Already downloaded: /Users/zwq/Library/Caches/Homebrew/downloads/39d7df008cc50d3b210bf837506888f3d7bdeae7ea87e77acfe51046dac723d9--nginx--1.21.1.mojave.bottle.tar.gz
==> Pouring nginx--1.21.1.mojave.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you don't want/need a background service you can just run:
nginx
==> Summary
🍺 /usr/local/Cellar/nginx/1.21.1: 25 files, 2.2MB