【2021/12/14】 Intel CPU mac 安装 homebrew 和 brew 安装php74
参考
- MacOS M1使用Homebrew搭建PHP运行环境
- Mac入门--通过Homebrew安装PHP(新)
- Homebrew / Linuxbrew 镜像使用帮助-清华大学开源软件镜像站 HOME EVENTS BLOG RSS PODCAST MIRRORS
原因
因为最新版本的mac os 不再包含php,需要进行手动安装。最简单的就是通过brew 包管理器进行安装了。
但是搜索了很多教程安装brew,虽然安装成功,但是都搜索不到php;并且还出现访问404之类的问题。
本文主要参考 清华大学开源软件镜像站 的帮助教程,然后一些需要注意的地方参考的 1、2 文章。
安装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"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
- 从镜像下载安装脚本并安装 Homebrew / Linuxbrew
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install
- 替换现有仓库上游
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do
brew tap --custom-remote --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
done
brew update
- 推荐用户将这两个环境变量设置加入 shell 的 profile 设置中。
test -r ~/.bash_profile && echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> ~/.bash_profile # bash
test -r ~/.bash_profile && echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.bash_profile
- 镜像迁移说明:Linuxbrew 核心仓库(linuxbrew-core)自 2021 年 10 月 25 日(brew 版本 3.3.0 起)被弃用,Linuxbrew 用户应迁移至 homebrew-core。Linuxbrew 用户请依新版镜像说明重新设置镜像。注意迁移前请先运行 brew update 将 brew 更新至 3.3.0 或以上版本。迁移过程中若出现任何问题,可使用如下命令重新安装 homebrew-core:
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
rm -rf "$(brew --repo homebrew/core)"
brew tap --custom-remote --force-auto-update homebrew/core https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
安装php步骤
- 终端搜索php
brew search php
# 输出
brew-php-switcher php@7.2 phplint pcp
php php@7.3 phpmd pup
php-code-sniffer php@7.4 ✔ phpmyadmin
php-cs-fixer php@8.0 phpstan
php-cs-fixer@2 phpbrew phpunit
- 安装
brew install php@7.4
- 安装完毕后php不能使用,还需要创建链接
brew link php@7.4
博 主 :夏秋初
地 址 :https://www.cnblogs.com/xiaqiuchu/articles/15689933.html
如果对你有帮助,可以点一下 推荐 或者 关注 吗?会让我的分享变得更有动力~
转载时请带上原文链接,谢谢。
地 址 :https://www.cnblogs.com/xiaqiuchu/articles/15689933.html
如果对你有帮助,可以点一下 推荐 或者 关注 吗?会让我的分享变得更有动力~
转载时请带上原文链接,谢谢。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义