新买了台mac,然后升级了个试用版操作系统,再安装php的时候,就出现了各种问题了。
关于openssl的扩展,确实会容易出现问题,有很多种办法,需要挨个尝试,总有一款合适的。
checking for krb5-config... /usr/bin/krb5-config
checking for DSA_get_default_method in -lssl... no
checking for X509_free in -lcrypto... yes
checking for pkg-config... no
configure: error: Cannot find OpenSSL's
出现这个错误,说明相关文件找不到,常见解决方案:
1. 卸载openssl,再安装openssl
root [~] brew cleanup
root [~] brew install openssl
2. 重装openssl
3. 依旧报错,添加制定配置
--with-openssl=/usr/local/opt/openssl
4. 将文件软链接到系统指定目录
ln: /usr/include: Operation not permitted
由于mac新的操作系统,是禁止直接操作/usr目录的,因此新版直接参考建议5。
5. 指定具体路径的软链接
root [~] ln -s ../opt/openssl/include/openssl .
解决了文件问题,可能还会报错其它问题,比如这个:
checking for pkg-config... /usr/local/bin/pkg-config
checking for OpenSSL version... >= 1.0.1
checking for CRYPTO_free in -lcrypto... no
configure: error: libcrypto not found!
6. 强制brew link更新
Warning: Refusing to link macOS-provided software: openssl
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
说明不建议这么使用,而是通过export方式进行修改。
7. export修改变量
root [~] export LDFLAGS="-L/usr/local/opt/openssl/lib"
root [~] export CPPFLAGS="-I/usr/local/opt/openssl/include"
然后继续报新的错误:
checking whether to enable PCRE JIT functionality... yes
checking whether to enable the SQLite3 extension... yes
checking bundled sqlite3 library... yes
checking for ZLIB support... yes
checking if the location of ZLIB install directory is defined... no
configure: error: Cannot find zlib
8. 继续指定相关路径
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--with-openssl=/usr/local/opt/openssl \
--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 \
GD库也跟着报错了:
checking for CRYPTO_free in -lcrypto... (cached) yes
checking for SSL_CTX_set_ssl_version in -lssl... (cached) yes
checking for GD support... yes
checking for the location of libwebp... no
checking for the location of libjpeg... yes
checking for the location of libpng... yes
checking for the location of libXpm... no
checking for FreeType 2... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=
configure: error: jpeglib.h not found.
9. 安装各类依赖库
root [~] brew install freetype
mac下手动安装确实复杂,不断根据错误提示进行安装。继续又报错了:
checking checking if we're at 64-bit platform... yes
checking for iconv support... yes
checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=
10. 安装libiconv
root [~] brew install libzip
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--with-openssl=/usr/local/opt/openssl \
--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 \
--with-iconv=/usr/local/Cellar/libiconv/1.16 \
--with-iconv-dir --with-freetype-dir \
--with-pdo-mysql \
--with-mysqli \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-mhash \
--enable-sockets \
--enable-ftp \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-gd \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--enable-fpm \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear
Leave a Reply