macos编译安装php7.4 报错:No package 'openssl' found

前言:编译参数

./configure --prefix=/usr/local/etc/php74 --with-config-file-path=/usr/local/etc/php74/etc --with-fpm-user=www --with-fpm-group=www --enable-fpm --with-bz2 --enable-gd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir --with-iconv-dir=/usr/local --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl --enable-dba --enable-bcmath --enable-calendar --with-gettext --with-pdo-mysql=mysqlnd --with-ldap --with-openssl --with-pear --with-xmlrpc --with-libdir=lib64 --with-libxml-dir --with-pcre-regex --with-pear --with-xsl --with-zlib --with-mhash --enable-libxml --enable-inline-optimization --enable-mbregex --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --with-zip

编译安装的时候报错:

No package 'openssl' found

1.检查是否安装openssl:

brew info openssl

#输出
openssl@1.1: stable 1.1.1d (bottled) [keg-only]

没安装的话运行安装命令:

brew install openssl@1.1

2.如果已经安装还是报错

编辑文件:

vi ~/.bash_profile

在文件末尾追加:

# pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

# openssl 个人本地的路径可能不同,以实际为准
export OPENSSL_LIBS="/usr/local/Cellar/openssl@1.1/1.1.1d/lib"
export OPENSSL_CFLAGS="/usr/local/Cellar/openssl@1.1/1.1.1d/include"

:wq保存!
重新加载环境变量:

source ~/.bash_profile

查看 openssl 是否在 pkgconfig 中:

#运行命令:
pkg-config --list-all | grep openssl

#输出:
libevent_openssl      libevent_openssl - libevent_openssl adds openssl-based TLS support to libevent

#没有 openssl 包说明没有成功注册openssl,需要手动建立

#openssl 个人本地的路径可能不同,以实际为准
#进入openssl的pkgconfig目录
cd /usr/local/Cellar/openssl@1.1/1.1.1d/lib/pkgconfig
#目录下有个openssl.pc的文件
#建立软链接
ln -s `pwd`/openssl.pc /usr/local/lib/pkgconfig

#重新运行命令查看
pkg-config --list-all | grep openssl
#输出:
openssl               OpenSSL - Secure Sockets Layer and cryptography libraries and tools
libevent_openssl      libevent_openssl - libevent_openssl adds openssl-based TLS support to libevent

成功!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容