赶知识网

pecl安装swoole扩展怎么开启openssl

2023-09-18 / 479次点击 php/mysql/apache swoole openssl pecl

使用命令进行安装:


pecl install swoole

pecl install --configureoptions 'enable-sockets="no" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="no" enable-swoole-curl="yes" enable-cares="yes"' swoole

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


enable sockets supports? [no] : 

enable openssl support? [no] : yes

enable mysqlnd support? [no] : 

enable curl support? [no] : yes

enable cares support? [no] : 

enable brotli support? [yes] : 


这些是用于开启某些特性,比如 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 库路径


就是这样的:


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

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


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

这样编译完成后就可以了


# 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


有用 没用

Top10

沪ICP备09053415号 © 赶知识网