php安装扩展event 提示 No package ‘openssl‘ found 解决方法

在使用pecl编译安装最新版event模块的时候提示 No package 'openssl' found , 可是本机是安装了openssl的, 编译时找不到, 大概率就是环境配置的问题了, 增加 OPENSSL_CFLAGS OPENSSL_LIBS环境变量即可解决.

异常提示信息:

bash 复制代码
checking for openssl >= 1.0.2... no
configure: error: Package requirements (openssl >= 1.0.2) 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.
ERROR: `/private/tmp/pear/temp/event/configure --with-php-config=/usr/local/opt/php/bin/php-config --enable-event-debug=yes --enable-event-sockets=yes --with-event-libevent-dir=/usr --with-event-pthreads --with-event-extra --with-event-openssl --with-event-ns=no --with-openssl-dir' failed

解决方法:

在 ~/.bash_profile 文件中增加以下环境变量配置, 注意将 /usr/local/opt/openssl@3 替换为你自己的openssl的安装路径

bash 复制代码
# add openssl lib to FLAGS
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
# 新版本需要的变量
export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@3/include"
export OPENSSL_LIBS="-L/usr/local/opt/openssl@3/lib"

生效配置

bash 复制代码
source ~/.bash_profile

重新安装:

bash 复制代码
pecl install event
相关推荐
亿坊电商14 小时前
PHP框架在微服务迁移中能发挥什么作用?
开发语言·微服务·php
帅云毅15 小时前
Web漏洞--XSS之订单系统和Shell箱子
前端·笔记·web安全·php·xss
keep intensify16 小时前
Linux常用指令
linux·服务器·php
ALex_zry17 小时前
Docker Macvlan网络配置实战:解决“network already exists“错误
网络·docker·php
Dachui_112217 小时前
MacOS上如何运行内网穿透详细教程
macos
布尼卡19 小时前
mac brew 无法找到php7.2 如何安装php7.2
php·mac
ALe要立志成为web糕手19 小时前
[BJDCTF2020]EzPHP
web安全·网络安全·php·ctf
Bruce_Liuxiaowei19 小时前
使用Python脚本在Mac上彻底清除Chrome浏览历史:开发实战与隐私保护指南
chrome·python·macos
农民也会写代码20 小时前
dedecms织梦arclist标签noflag属性过滤多个参数
开发语言·数据库·sql·php·dedecms
iFlyCai1 天前
对Mac文字双击或三击鼠标左键没有任何反应
macos·计算机外设