安装 php@7.4
brew search php
brew install php@7.4
#安装brew时用的是清华的源
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
#安装php时改成阿里的源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
#我这台机器用的环境变量在这个文件
source ~/.zprofile
#安装时有两个文件404没有下载下来,它是回地官方源下载,但安装时名字还是用阿里的名字,所以打不到包,手动到缓存目录里改的。改成安装需要的包的名字。
~/Library/Caches/Homebrew/downloads/
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/libnghttp2-1.45.1.arm64_big_sur.bottle.tar.gz
#=#=#
curl: (22) The requested URL returned error: 404
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/manifests/1.45.1
Already downloaded: ~/Library/Caches/Homebrew/downloads/a10e8809f2b80ff379c8ac93e0e41e69e5a179b36e2ac19968bcfec8abe11b73--libnghttp2-1.45.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/blobs/sha256:75ed9aea6aad424ff9406f7c8849d340d5f2fb36b05c9352f8416201fe03d1df
Already downloaded: ~/Library/Caches/Homebrew/downloads/c02fdc0e3d56ae7272e012ca27f72376f0e4fa1982db36153ab382cbb121ed67--libnghttp2--1.45.1.arm64_big_sur.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - ~/Library/Caches/Homebrew/downloads/337a90e2920c64fc59fd947a51f52ced2a427882135b8cc6e3d5fd80a32ca4a1--libnghttp2-1.45.1.arm64_big_sur.bottle.tar.gz
将 c02fdc0e3d56ae7272e012ca27f72376f0e4fa1982db36153ab382cbb121ed67--libnghttp2--1.45.1.arm64_big_sur.bottle.tar.gz 改名成 337a90e2920c64fc59fd947a51f52ced2a427882135b8cc6e3d5fd80a32ca4a1--libnghttp2-1.45.1.arm64_big_sur.bottle.tar.gz