现在再宝塔中直接安装Swoole扩展,是4.2.10版本,但是这个版本有个bug,官方暂未解释。

  1. swoole4.2.10 使用swoole_process报错,must be forked outside the coroutine

【后期修复文章,统一安装4.5.0版本,PHP需要使用7.3+以上版本】
所以我们安装4.5.0,手动安装教程如下:

  1. wget http://pecl.php.net/get/swoole-4.5.0.tgz
  2. tar -zxvf swoole-4.5.0.tgz
  3. cd swoole-4.5.0
  4. phpize
  5. ./configure --with-php-config=/www/server/php/73/bin/php-config --enable-openssl
  6. make
  7. make install
  8. # 修改php.ini,末尾加上下面这句
  9. extension=swoole.so
  10. 保存,重启php服务器
  11. php -m
  12. 查看扩展是否安装成功

如果你要自己指定openssl的地址,还可以在./configure末尾,加上--with-openssl-dir=/usr/bin/openssl