当尝试定制 Dockerfile时,发现电脑里没有PHP安装 于是自己进行了摸索

解决办法

brew install php

反馈

image.png

定制 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>

反馈

image.png

Homebrew 的 homebrew-core 没有被正确安装,导致终端无法进入相应的目录

安装homebrew-core

解决办法

手动安装 homebrew-core

brew tap homebrew/core

反馈

image.png

解决办法

直接替换 homebrew-core 的镜像源

git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git>

反馈

image.png

解决办法

尝试强制 tap homebrew-core

brew tap homebrew/core --force

检查 homebrew-core 是否成功创建

ls $(brew --repo homebrew/core)

反馈

image.png

说明homebrew-core 目录已经成功创建,包含了相关文件

验证和更新 Homebrew

git -C "$(brew --repo homebrew/core)" remote -v

反馈

image.png

说明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

反馈

image.png

页面一直卡在这里,不动

解决办法

手动重启 Homebrew 更新

# 按 Ctrl + C 停止更新
brew update --force --quiet

页面一直卡在这里,不动

解决办法

关闭VPN 并输入bash(verbose可以展示更详细的更新日志)

brew update --verbose

反馈

image.png

说明Homebrew 已经成功更新

再次尝试安装PHP

brew install php
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!