前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >pecl安装swoole扩展怎么开启openssl

pecl安装swoole扩展怎么开启openssl

作者头像
沈唁
发布2019-12-09 13:20:46
4.7K0
发布2019-12-09 13:20:46
举报
文章被收录于专栏:沈唁志

这是一篇基础知识补习文章,大多数新手在安装 Swoole 扩展时,都只会使用 pecl 进行安装,还要增加一些编译参数,比如 openssl

使用命令进行安装:

代码语言:javascript
复制
pecl install swoole

在使用 pecl 进行安装时有几个问答选项

代码语言:javascript
复制
enable sockets supports? [no] : 
enable openssl support? [no] : 
enable http2 support? [no] : 
enable mysqlnd support? [no] : 

这些是用于开启某些特性,比如 openssl 是来启用 SSL 支持,大多数新手在这里都会选择 yes,之后就开始编译了

结果发现报错了:error "Enable openssl support, require openssl library."(具体的错误信息就不详细写了,大概是这样)意思就是说你开启 openssl,常规路径下没有找到,需要你手动指定 openssl 库的路径

或者fatal error: 'openssl/ssl.h' file not found

这个意思是你没有加 openssl 库的路径或者指定 openssl 库的路径不对,缺少头文件

那么在 pecl 安装的时候怎么开启添加这个路径呢?不是只能 yes 或者 no 吗?

答案是当然可以添加的,我们可以在 yes 后面跟上路径参数: --with-openssl-dir=/opt/openssl/,替换为你的 openssl 库路径

就是这样的:

代码语言:javascript
复制
enable sockets supports? [no] : yes
enable openssl support? [no] : yes --with-openssl-dir=/usr/include/openssl
enable http2 support? [no] : no
enable mysqlnd support? [no] : yes

下面我们就可以看到我们的编译参数:

代码语言:javascript
复制
building in /tmp/pear/temp/pear-build-rootVseYYu/swoole-4.4.8
running: /tmp/pear/temp/swoole/configure --with-php-config=/usr/local/php/bin/php-config --enable-sockets=yes --enable-openssl=yes --with-openssl-dir=/usr/include/openssl --enable-http2=no --enable-mysqlnd=yes

这样编译完成后就可以了

代码语言:javascript
复制
# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team 
Version => 4.4.8
Built => Oct 17 2019 11:18:01
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2k-fips  26 Jan 2017
http2 => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608

沈唁志,一个PHPer的成长之路! 任何个人或团体,未经允许禁止转载本文:《pecl安装swoole扩展怎么开启openssl》,谢谢合作!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-10-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档