我使用这个命令在我的 macOS 上编译 php:
./configure \
--prefix=/opt/php-7.4.30 \
--with-config-file-path=/opt/php-7.4.30/etc \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv=/opt/homebrew/Cellar/libiconv/1.17 \
--with-zlib-dir=/opt/homebrew/Cellar/zlib/1.2.12_1 \
--with-bz2=/opt/homebrew/Cellar/bzip2/1.0.8 \
--with-openssl=/opt/homebrew/Cellar/openssl@3/3.0.5/\
--with-curl=/opt/homebrew/Cellar/curl/7.85.0 \
--enable-soap \
--enable-mbstring \
--enable-sockets \
--enable-exif \
--with-readline=/opt/homebrew/Cellar/readline/8.1.2 \
--disable-ipv6
在我的 macOS 中,我确实有/opt/homebrew/Cellar/openssl@3/3.0.5/
% ls /opt/homebrew/Cellar/openssl@3/3.0.5/
AUTHORS INSTALL_RECEIPT.json NEWS bin lib
CHANGES LICENSE README include share
我得到以下错误:
Configuring extensions
checking io.h usability... no
checking io.h presence... no
checking for io.h... no
checking for strtoll... yes
checking for atoll... yes
checking whether to build with LIBXML support... yes
checking for libxml-2.0 >= 2.7.6... yes
checking for OpenSSL support... yes
checking for Kerberos support... no
checking whether to use system default cipher list instead of hardcoded value... no
checking for openssl >= 1.0.1... no
configure: error: Package requirements (openssl >= 1.0.1) were not met:
No package 'openssl' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables OPENSSL_CFLAGS
and OPENSSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
编辑-01
在问这个问题之前,我尝试过:
export OPENSSL_CFLAGS="/opt/homebrew/Cellar/openssl@3/3.0.5/include"
export OPENSSL_LIBS="/opt/homebrew/Cellar/openssl@3/3.0.5/lib"
export PKG_CONFIG_PATH=/opt/homebrew/Cellar/openssl@3/3.0.5/lib/pkgconfig:$PKG_CONFIG_PATH