Macos开启Swoole的Openssl
本来呢我的macos上已经安装好了 swoole v5.1.4
查看信息
执行 php --ri swoole
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.1.4
Built => Sep 16 2024 19:28:05
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
http2 => enabled
json => enabled
pcre => enabled
zlib => 1.2.12
brotli => E16781312/D16781312
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
但是我在使用 Guzzle
包的时候提示给我如下报错error.ERROR: you must configure with
--enable-opensslto support ssl connection when compiling Swoole
好吧没办法只能重新编译安装了
安装 openssl
//搜索 openssl
brew search openssl
//查看 openssl
brew info openssl
//安装 openssl
brew install openssl
重新编译安装 swoole v5.1.4
//下载链接
https://github.com/swoole/swoole-src/archive/refs/tags/v5.1.4.tar.gz
//解压
tar -xzf swoole-src-5.1.4.tar.gz
cd swoole-src-5.1.4
//编译
./configure --enable-openssl --enable-http2
make && make install
然后没有意外的在这个时候就意外发生了。报错了,报错如下
shell
fatal error: 'pcre2.h' file not found
23 | #include "pcre2.h"
| ^~~~~~~~~
1 error generated.
make: *** [ext-src//php_swoole.lo] Error 1
解决方案
ln -s /opt/homebrew/include/pcre2.h /opt/homebrew/Cellar/php/8.3.12_1/include/php/ext/pcre/pcre2.h
然后继续执行 make && make install
安装后查看信息
这个时候咱们再执行一次 php --ri swoole
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.1.4
Built => Dec 8 2024 22:22:22
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
openssl => OpenSSL 3.3.2 3 Sep 2024
dtls => enabled
http2 => enabled
json => enabled
pcre => enabled
zlib => 1.2.12
brotli => E16781312/D16781312
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
然后再请求使用 Guzzle
包发现已经好了