安装swoole扩展两种方式1. pecl 2. 编译安装


  • 宿机win10
  • 操作主机vbox-ubuntu
  • 安装主机docker [letsdockerize/laradock-php-fpm:2.4-7.2]


pecl install swoole-4.4.4

执行上面命令后待定一段时间后、会出现下面询问对话输入[y]就是开启, 但是在dockerfile中无法自动为其输入[y]. 方法未找到. dockerfile可以使用编译方式安装.

381 source files, building
running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
enable sockets supports? [no] : 
enable openssl support? [no] : 
enable http2 support? [no] : 
enable mysqlnd support? [no] : 
building in /tmp/pear/temp/pear-build-defaultusernDqLij/swoole-4.4.1


    curl -o /tmp/swoole.tar.gz https://github.com/swoole/swoole-src/archive/v4.4.1.tar.gz -L && \
    tar zxvf /tmp/swoole.tar.gz && cd swoole-src* && \
    phpize && \
    ./configure \
    --enable-openssl  \
    --enable-http2  \
    --enable-async-redis \
    --enable-mysqlnd && \
    make && make install && \
    docker-php-ext-enable swoole


php --ri swoole


root@4c5bf38c1a5d:/var/www/html# php --ri swoole


Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.4.1
Built => Sep  6 2019 05:54:34
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.1.0j  20 Nov 2018
http2 => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
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 => 8388608 => 8388608

pecl install 参数选择 pecl help install

  -f, --force
        will overwrite newer installed packages
  -l, --loose
        do not check for recommended dependency version
  -n, --nodeps
        ignore dependencies, install anyway
  -r, --register-only
        do not install files, only register the package as installed
  -s, --soft
        soft install, fail silently, or upgrade if already installed
  -B, --nobuild
        don't build C extensions
  -Z, --nocompress
        request uncompressed files when downloading
  -R DIR, --installroot=DIR
        root directory used when installing files (ala PHP's INSTALL_ROOT), use packagingroot for RPM
  -P DIR, --packagingroot=DIR
        root directory used when packaging files, like RPM packaging
        force install even if there were errors
  -a, --alldeps
        install all required and optional dependencies
  -o, --onlyreqdeps
        install all required dependencies
  -O, --offline
        do not attempt to download any urls or contact channels
  -p, --pretend
        Only list the packages that would be downloaded


pecl 安装swoole怎么开启openssl | 如果是 Nginx 代理到 Swoole,那么 Swoole 不需要配置 SSL 编译Swoole时指定--enable-openssl或--with-openssl-dir可以开启SSL

expect - 自动交互脚本 待研究