安装 shivammathur/php Tap(使用中科大镜像)
由于 shivammathur/php 是第三方 Tap,中科大没有直接镜像,但我们可以手动修改它的 Git 远程地址:
# 先尝试正常添加 Tap(可能会失败,但能创建目录)
brew tap shivammathur/php || true
# 进入 Tap 目录
cd "$(brew --prefix)/Library/Taps/shivammathur/homebrew-php"
# 更换为中科大的 Homebrew PHP 镜像(如果存在)
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-php.git
# 如果中科大没有镜像,可以尝试改用 SSH(需配置 GitHub SSH Key)
git remote set-url origin git@github.com:shivammathur/homebrew-php.git
# 拉取更新
git pull
直接手动安装
如果 Git 失败:
访问 shivammathur/homebrew-php :https://github.com/shivammathur/homebrew-php
下载 ZIP 文件
解压到正确路径:
unzip homebrew-php-master.zip -d $(brew --prefix)/Library/Taps/shivammathur/homebrew-php