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
相关推荐
jwn9994 分钟前
Laravel6.x核心特性全解析
开发语言·php·laravel
總鑽風30 分钟前
搭建Spring Boot + ELK日志平台,实现可视化日志监控
spring boot·elk·macos
星辰徐哥1 小时前
5G的行业应用:工业互联网、车联网、智慧医疗中的网络支撑
网络·5g·php
三道渊2 小时前
进程通信与网络协议
开发语言·数据库·php
流觞 无依2 小时前
DedeCMS plus/download.php SQL注入漏洞修复教程
sql·php
Freak嵌入式3 小时前
MicroPython LVGL基础知识和概念:显示与多屏管理
开发语言·python·github·php·gui·lvgl·micropython
Freak嵌入式4 小时前
MicroPython LVGL基础知识和概念:时序与动态效果
开发语言·python·github·php·gui·lvgl·micropython
fengci.6 小时前
php反序列化(复习)(第三章)
android·开发语言·学习·php
说实话起个名字真难啊6 小时前
Docker 入门之网络基础
网络·docker·php
竹之却6 小时前
【Agent-阿程】openclaw v2026.4.9更新内容介绍
开发语言·php·openclaw·openclaw 更新