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

M2 Mac用Homebrew安装PHP失败:freetds下载提示curl未安装

问题描述

在M2 Macbook(MacOS Ventura 13.4)上通过Homebrew安装PHP,执行brew install php时出现以下错误:

Error: php: Failed to download resource "freetds"
Download failed: Homebrew-installed `curl` is not installed for: https://www.freetds.org/files/stable/freetds-1.3.18.tar.bz2

按提示执行brew install curl后,再次安装PHP仍报相同错误。重新安装curl时,其依赖openssl@1.1编译失败,日志片段如下:

==> Installing curl dependency: openssl@1.1
==> perl ./Configure --prefix=/Users/ciesinsg/homebrew/Cellar/openssl@1.1/1.1.1u --openssldir=/Users/
==> make
Last 15 lines from /Users/ciesinsg/Library/Logs/Homebrew/openssl@1.1/02.make:
clang  -I. -Iinclude -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/Users/ciesinsg/homebrew/etc/openssl@1.1\"" -DENGINESDIR="\"/Users/ciesinsg/homebrew/Cellar/openssl@1.1/1.1.1u/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -MMD -MF crypto/sha/sha1_one.d.tmp -MT crypto/sha/sha1_one.o -c -o crypto/sha/sha1_one.o crypto/sha/sha1_one.c
clang  -I. -Iinclude -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/Users/ciesinsg/homebrew/etc/openssl@1.1\"" -DENGINESDIR="\"/Users/ciesinsg/homebrew/Cellar/openssl@1.1/1.1.1u/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -MMD -MF crypto/sha/sha1dgst.d.tmp -MT crypto/sha/sha1dgst.o -c -o crypto/sha/sha1dgst.o crypto/sha/sha1dgst.c
CC="clang" perl crypto/sha/asm/sha512-armv8.pl ios64 crypto/sha/sha256-armv8.S
clang  -I. -Iinclude -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/Users/ciesinsg/homebrew/etc/openssl@1.1\"" -DENGINESDIR="\"/Users/ciesinsg/homebrew/Cellar/openssl@1.1/1.1.1u/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -MMD -MF crypto/sha/sha256.d.tmp -MT crypto/sha/sha256.o -c -o crypto/sha/sha256.o crypto/sha/sha256.c
CC="clang" perl crypto/sha/asm/sha512-armv8.pl ios64 crypto/sha/sha512-armv8.S
clang  -I. -Iinclude -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/Users/ciesinsg/homebrew/etc/openssl@1.1\"" -DENGINESDIR="\"/Users/ciesinsg/homebrew/Cellar/openssl@1.1/1.1.1u/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -MMD -MF crypto/sha/sha512.d.tmp -MT crypto/sha/sha512.o -c -o crypto/sha/sha512.o crypto/sha/sha512.c
make[1]: /bin/sh: line 1:  1129 Killed: 9               mv crypto/seed/seed_ofb.d.tmp crypto/seed/seed_ofb.d
*** [crypto/sha/sha1_one.o] Killed: 9
make[1]: *** Waiting for unfinished jobs....
make[1]: error closing STDOUT:  at crypto/sha/asm/sha1-armv8.pl line 364.
*** [crypto/sha/sha1dgst.o] Killed: 9
make[1]: *** [crypto/sha/sha512.o] Killed: 9
make[1]: *** [crypto/sha/sha1-armv8.S] Error 255
make[1]: *** [crypto/seed/seed_ofb.o] Error 137
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/homebrew-core!

执行curl --version显示系统已安装x86_64版本的curl:

curl 7.88.1 (x86_64-apple-darwin22.0) libcurl/7.88.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0
Release-Date: 2023-02-20
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets
原因分析
  1. Homebrew curl未被识别:系统自带的是x86_64架构的curl,而M2为arm64架构,Homebrew默认要求使用自身编译的arm64版本curl下载资源,因此会提示"Homebrew-installed curl is not installed"。
  2. openssl@1.1编译失败:日志中的Killed:9是系统内存不足触发OOM Killer终止进程导致的;另外openssl@1.1已停止维护,Homebrew在arm64架构上对其支持有限,也会加剧编译失败的概率。
解决方案

步骤1:释放系统内存

  • 关闭后台闲置应用,释放运行内存;
  • 临时扩容虚拟内存:打开「系统设置」→「通用」→「储存空间」→「信息」→「管理」→「存储」→「虚拟内存」,勾选「启用虚拟内存」并分配至少8GB空间。

步骤2:安装兼容的curl版本

执行以下命令安装使用系统TLS库的curl,跳过openssl@1.1依赖:

brew install curl --with-secure-transport

若仍有问题,可临时使用系统curl替代Homebrew版本:

# zsh用户
echo 'export HOMEBREW_FORCE_BREWED_CURL="false"' >> ~/.zshrc
source ~/.zshrc

# bash用户
echo 'export HOMEBREW_FORCE_BREWED_CURL="false"' >> ~/.bash_profile
source ~/.bash_profile

步骤3:重新安装PHP

完成上述操作后,执行命令重新安装:

brew install php

备选方案:使用预编译二进制包

若编译问题持续,直接使用Homebrew预编译的PHP包:

brew install php --force-bottle

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 20:42:11