安装PHP的swoole扩展报错解决方案

pecl install swoole

安装swoole,下载完成会提示:

enable sockets supports? [no] : yes
enable openssl support? [no] : yes
enable http2 support? [no] : yes
nable mysqlnd support? [no] :

会提示报错:

In file included from /private/tmp/pear/temp/swoole/php_swoole_cxx.cc:1:
In file included from /private/tmp/pear/temp/swoole/php_swoole_cxx.h:19:
In file included from /private/tmp/pear/temp/swoole/php_swoole.h:53:
/private/tmp/pear/temp/swoole/include/swoole.h:620:10: fatal error: 'openssl/ssl.h' file not found
#include 
         ^~~~~~~~~~~~~~~
1 error generated.
make: *** [php_swoole_cxx.lo] Error 1
ERROR: `make' failed

我的系统是Mac,安装openssl会提示已安装:

brew install openssl
Updating Homebrew...
Warning: openssl@1.1 1.1.1d is already installed and up-to-date
To reinstall 1.1.1d, run `brew reinstall openssl@1.1`

那肯定是openssl位置没找到,重新执行:

pecl install swoole

在openssl指定其位置

enable sockets supports? [no] : yes
enable openssl support? [no] : yes --with-openssl-dir=/usr/local/opt/openssl@1.1
enable http2 support? [no] : yes
nable mysqlnd support? [no] :

查询一下安装成功

php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team 
Version => 4.4.16
Built => Mar 11 2020 18:15:36
coroutine => enabled
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1d  10 Sep 2019
http2 => 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 => On => On
swoole.unixsock_buffer_size => 262144 => 262144
联系我们

邮箱 626512443@qq.com
电话 18611320371(微信)
QQ群 235681453

Copyright © 2015-2024

备案号:京ICP备15003423号-3