You need to enable JavaScript to run this app. 如何在MacOS Big Sur中让命令行使用Homebrew安装的PHP而非系统预装版本
优惠活动
大模型
产品
解决方案
定价
更多

如何在MacOS Big Sur中让命令行使用Homebrew安装的PHP而非系统预装版本

问题场景
  • 已通过Homebrew安装了更新版本的PHP 7.4,且完成了Apache端的对应PHP版本配置,通过PHP脚本运行phpinfo可验证Web环境已正常使用目标PHP版本。
  • 命令行执行php -v命令时,仍返回macOS系统预装PHP的相关提示:
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Dec 21 2020 21:33:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
  • 从输出结果可确认,当前命令行环境仍在调用macOS自带的预装PHP。
待解决问题

需要完成哪些配置操作,才能让命令行环境优先调用Homebrew安装的PHP版本?

phpinfo配置截图


内容的提问来源于stack exchange,提问作者delphirules

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.03 12:24:01