mac上brew安装swoole扩展,采坑之路

1、官网下载最新扩展

wget http://pear.php.net/go-pear.phar

说明:如果提醒你需要更新,则更新命令

2、开始安装

sudo pecl install swoole

tips:如果提示没有pecl命令,则通过brew install pecl

brew install pecl

3、配置

Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
enable sockets supports? [no] : yes
enable openssl support? [no] : yes --with-openssl-dir=/usr/local/Cellar/openssl@1.1/1.1.1i/
enable http2 support? [no] : yes
enable mysqlnd support? [no] : yes

每个配置项的意义:自行google,参考链接
tips:特别提醒的是:openssl一定要根据自身环境来配置正确的路径,鄙人就是在这个问题上费了好大劲,因为没有配置准确路劲,导致错误如下:Enable openssl support, require openssl library

4、安装成功

Build process completed successfully
Installing '/usr/local/Cellar/php@7.4/7.4.13_1/include/php/ext/swoole/config.h'
Installing '/usr/local/Cellar/php@7.4/7.4.13_1/pecl/20190902/swoole.so'
install ok: channel://pecl.php.net/swoole-4.5.10
Extension swoole enabled in php.ini

通过 php -v
显示
在这里插入图片描述

5、配置php.ini文件

sudo vi /usr/local/etc/php/7.4/php.ini

增加swoole扩展

extension="swoole.so"

6、重启apache

sudo apachectl restart

至此,mac上brew安装swoole版本成功;

安装过程中可能出现的错误:
1 fatal error: ‘openssl/ssl.h‘ file not found
解决方法1:cp -R /usr/local/opt/openssl/include/openssl /usr/local/include

解决方法2:ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl

原因:一般用brew安装的软件,都会把需要include的文件自动放到/usr/local/include里的,但是不知为什么安装openssl的时候没有放到那里,所以要自己拷过去,其实最好的方法是做一个链接,即用解决方法2!

详情查看,网友提供方案:[swoole安装问题集锦(https://www.cnblogs.com/xiaobaiskill/p/11062024.html)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值