幸福

如人饮水,冷暖自知

you must configure with `--enable-openssl` to support ssl connection when compiling Swoole

Mac环境下,升级了下开发环境的相关应用版本,运行swoole类框架报错:

[ERROR] you must configure with `–enable-openssl` to support ssl connection when compiling Swoole

> php –ri swoole 查看了下安装的swoole扩展,确实没有开启openssl ,

Swoole => enabled

Author => Swoole Team <team@swoole.com>

Version => 4.5.5

Built => Oct 29 2020 10:47:30

coroutine => enabled

kqueue => enabled

rwlock => enabled

pcre => enabled

zlib => 1.2.11

brotli => E16777223/D16777223

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 => Off => Off

swoole.unixsock_buffer_size => 262144 => 262144

犹豫之前已经通过homebrew安装过openssl了,所以下了个swoole当前最新版本v4.5.5的包,进行重新编译:

rm -rf configure*

/usr/local/Cellar/php@7.2/7.2.20/bin/phpize

./configure –enable-openssl –with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s –enable-openssl –with-php-config=/usr/local/Cellar/php@7.2/7.2.20/bin/php-config

反正是各种编译,都不生效,然后尝试通过pecl方式重新安装swoole,又遇到新的问题:

fatal error: ‘openssl/ssl.h’ file not found

 原因:MacOSX10.11开始就没有openssl了,用的是LibreSSL

# 查询 openssl 的安装目录
brew –prefix openssl

>/usr/local/opt/openssl@1.1

确实已经安装过了

然后直接通过 pecl install swoole 重新安装时,已经报错

尝试更改了 ~/.bash_profile

export LD_LIBRARY_PATH=$(brew –prefix openssl)/lib

export CPATH=$(brew –prefix openssl)/include

export PKG_CONFIG_PATH=$(brew –prefix openssl)/lib/pkgconfig

重启生效 source ~/.bash_profile

重新安装 pecl install swoole 发现涛声依旧

于是拷贝openssl到指定目录

cp -r /usr/local/Cellar/openssl/1.0.2s/include/openssl  /usr/local/include/openssl

然后直接通过 pecl install swoole 重新安装时,还是报错,不过已经换了个错误

error:”Enable openssl support, require openssl library”

于是乎重新安装,然后指定了下目录

AR/Builder.php on line 310
running: phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
enable sockets supports? [no] : yes
enable openssl support? [no] : yes –with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s
enable http2 support? [no] : yes
enable mysqlnd support? [no] : yes

……

Build process completed successfully

查看扩展明细 php –ri swoole ,已经安装成功

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.5.5
Built => Oct 29 2020 21:04:32
coroutine => enabled
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2s 28 May 2019
http2 => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777223/D16777223
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 => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144

而后服务运行正常!



去打赏

您的支持将鼓励我们继续创作!

[微信] 扫描二维码打赏

[支付宝] 扫描二维码打赏

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注