mac mysql安装sll_mac下安装php报错openssl等错误

在新mac上安装PHP时遇到openssl等相关错误。通过卸载并重新安装openssl,设置软链接,调整环境变量,安装依赖库如zlib、webp、freetype、libiconv和libzip等,逐步解决configure报错问题。
摘要由CSDN通过智能技术生成

新买了台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 uninstall openssl

root [~] brew cleanup

root [~] brew install openssl

2. 重装openssl

root [~] brew reinstall openssl

3. 依旧报错,添加制定配置

--with-openssl=/usr/local/opt/openssl

4. 将文件软链接到系统指定目录

root [~] sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include

ln: /usr/include: Operation not permitted

由于mac新的操作系统,是禁止直接操作/usr目录的,因此新版直接参考建议5。

5. 指定具体路径的软链接

root [~] cd /usr/local/include

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更新

root [~] brew link openssl --force

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 PATH="/usr/local/opt/openssl/bin:$PATH"

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 webp

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 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值