安装步骤:
1、下载源码
git clone https://github.com/swoole/swoole-src.git
2、进入swoole文件夹,生成configure
cd swoole-src
sudo /usr/local/Cellar/php@7.4/7.4.13_1/bin/phpize [找到你自己安装对应的phpize的绝对路径]
3、编译安装 (多个php版本的情况,需要指定版本conifg)
sudo ./configure --enable-openssl --with-openssl-dir=/usr/local/opt/openssl --with-php-config=/usr/local/Cellar/php@7.4/7.4.13_1/bin/php-config [找到你自己安装对应的php-config的绝对路径]
如果要swoole支持openssl 带上上面的 如果不需要 自己去掉。
sudo make
sudo make install
4、输出
Installing shared extensions: /usr/local/Cellar/php@7.4/7.4.13_1/pecl/20190902/
Installing header files: /usr/local/Cellar/php@7.4/7.4.13_1/include/php/
5、修改php.ini
第三个坑:一定要找到指定php版本的php.ini
/usr/local/etc/php/7.4/php.ini
添加扩展,上面复制的路径,添加到最后一行:
extension=swoole.so
swoole.use_shortname = ‘off’//如果使用hyperf 这句要加上
6、重启php-fpm
7、重启nginx