当我尝试用brew install PHP with my high sierra安装PHP时,我得到了这个错误:
clang -I. -Iinclude -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR=""/usr/local/etc/openssl@1.1"" -DENGINESDIR=""/usr/local/Cellar/openssl@1.1/1.1.1l/lib/engines-1.1"" -D_REENTRANT -DNDEBUG -MMD -MF crypto/rand/rand_unix.d.tmp -MT crypto/rand/rand_unix.o -c -o crypto/rand/rand_unix.o crypto/rand/rand_unix.c
In file included from crypto/rand/rand_unix.c:38:
/usr/include/CommonCrypto/CommonRandom.h:35:9: error: unknown type name 'CCCryptorStatus'
typedef CCCryptorStatus CCRNGStatus;
^
crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'
if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
^
2 errors generated.
make[1]: *** [crypto/rand/rand_unix.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
问题与openssl包有关。
我在这里找到了解决方案:
macOS 10.12 brew install openssl issue
使用以下brew edit openssl
编辑openssl然后加上一行:
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
指向configure_args
中的args数组,如下所示:
def configure_args
args = %W[
--prefix=#{prefix}
--openssldir=#{openssldir}
no-ssl3
no-ssl3-method
no-zlib
##### add the line here ####
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
]
on_linux do
args += (ENV.cflags || "").split
args += (ENV.cppflags || "").split
args += (ENV.ldflags || "").split
args << "enable-md2"
end
args
end
然后再尝试安装PHP。我安装了php@7.4.
brew install php@7.4