当尝试定制 Dockerfile时,发现电脑里没有PHP安装 于是自己进行了摸索
解决办法
brew install php
反馈
定制 Dockerfile
php artisan sail:publish
反馈
zsh: command not found: php
查询PHP版本
php -v
反馈
zsh: command not found: php
可能的原因
Error: php: Failed to download resource "zstd"
curl: (35) Recv failure: No route to host
这个错误通常是由于网络连接问题导致的,具体来说是 Homebrew 在尝试下载 zstd 包时,无法连接到远程服务器。这种问题可以通过以下几种方法来解决。
解决方法
清理 Homebrew 缓存
有时缓存的文件可能损坏,导致下载失败。你可以通过清理 Homebrew 的缓存并重新安装来解决:
brew cleanup
brew install php
反馈
网络请求失败
解决办法
尝试替换为国内镜像源
首先替换主仓库
git -C "$(brew --repo)" remote set-url origin <https://mirrors.aliyun.com/homebrew/brew.git>
然后替换homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git>
反馈
Homebrew 的 homebrew-core 没有被正确安装,导致终端无法进入相应的目录
安装homebrew-core
解决办法
手动安装 homebrew-core
brew tap homebrew/core
反馈
解决办法
直接替换 homebrew-core 的镜像源
git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git>
反馈
解决办法
尝试强制 tap homebrew-core
brew tap homebrew/core --force
检查 homebrew-core 是否成功创建
ls $(brew --repo homebrew/core)
反馈
说明homebrew-core 目录已经成功创建,包含了相关文件
验证和更新 Homebrew
git -C "$(brew --repo homebrew/core)" remote -v
反馈
说明homebrew-core 的远程仓库依然指向 GitHub 的官方源 (github.com/Homebrew/homebrew-core),没有切换为阿里云的镜像源
解决办法
手动替换 homebrew-core 的远程仓库
git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git>
验证替换是否成功
git -C "$(brew --repo homebrew/core)" remote -v
反馈
origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git> (fetch)
origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git> (push)
说明替换成功
更新 Homebrew
brew update
反馈
页面一直卡在这里,不动
解决办法
手动重启 Homebrew 更新
# 按 Ctrl + C 停止更新
brew update --force --quiet
页面一直卡在这里,不动
解决办法
关闭VPN 并输入bash(verbose可以展示更详细的更新日志)
brew update --verbose
反馈
说明Homebrew 已经成功更新
再次尝试安装PHP
brew install php