End.

swoole开启openssl

swoole http请求报错“you must configure with --enable-openssl to support ssl connection when ……”
“PHP Fatal error: Uncaught Swoole\Coroutine\Http\Client\Exception: you must configure with --enable-openssl to support ssl connection when compiling Swoole”

原因:

swoole扩展没有开启openssl

解决方法

swoole重新安装,启动openssl

swoole官网安装教程


1、下载解压

wget https://gitee.com/swoole/swoole/repository/archive/v4.4.26?format=tar.gz
# 解压
tar -zxvf v4.4.26\?format\=tar.gz
cd swoole-v4.4.26


2、查看php-config路径,phpize安装

whereis php-config

[root@localhost hcApi]# whereis php-config php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz


phpize


./configure --enable-openssl --enable-http2 --with-php-config=/usr/bin/php-config
make && make install



3、检查是否成功

php --ri swoole
[root@localhost hcApi]# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.4.26
Built => Apr  1 2022 20:47:26
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2k-fips  26 Jan 2017
http2 => enabled
pcre => enabled
zlib => 1.2.7
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled
End.