You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac Intel执行php -v报错:缺失_nghttp2相关符号求助

Mac Intel设备上PHP执行php -v报错的解决办法

执行php -v时出现如下报错:

➜  ~ php -v
dyld[8243]: Symbol not found: (_nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation)
  Referenced from: '/usr/local/Cellar/curl/7.87.0/lib/libcurl.4.dylib'
  Expected in: '/usr/local/Cellar/libnghttp2/1.47.0/lib/libnghttp2.14.dylib'
[1]    8243 abort      php -v

该问题是手动卸载icu4c 71版本并安装70版本后,引发的依赖库版本不兼容——curl依赖的libnghttp2符号在当前安装的libnghttp2版本中不存在,导致PHP启动时触发错误。

解决步骤:

  • 强制卸载当前的libnghttp2和curl,清除不兼容的版本:
    brew uninstall --force libnghttp2 curl
    
  • 重新安装curl,让brew自动匹配兼容的libnghttp2版本:
    brew install curl
    
    若需指定特定版本(比如匹配PHP所需依赖),可先搜索可用版本再安装:
    brew search libnghttp2
    brew install libnghttp2@1.52.0 # 示例版本,请根据实际兼容情况调整
    
  • 重新链接curl和libnghttp2,确保系统优先使用brew安装的库:
    brew link --force curl
    brew link --force libnghttp2
    
  • 重新安装或链接PHP,使其重新识别正确的依赖库:
    brew reinstall php
    # 或使用链接命令:brew link --force php
    

补充方案:

如果上述步骤无效,执行以下命令清理brew缓存并检查依赖问题:

brew cleanup
brew doctor

根据brew doctor输出的提示修复潜在问题后,再重新执行安装步骤。

内容的提问来源于stack exchange,提问作者Abdullah Al Mamun

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 22:25:27