1、下载swoole最新源码(以swoole4.4.14为例)后解压至任意目录,并进入其中:
cd swoole-src-4.4.14
2、使用phpize生成configure文件
(phpize编译PHP扩展的工具,主要是根据系统信息生成对应的configure文件,详情请参考官方文档:https://www.php.net/manual/en/install.pecl.phpize.php)。
不确定phpize的位置可以先查找一下即可:
xiongxudeMacBook-Pro:swoole-src-4.4.14 xmsite$ find / -name phpize/usr/bin/phpize
执行/usr/bin/phpize后结果如下:
xiongxudeMacBook-Pro:swoole-src-4.4.14 xmsite$ /usr/bin/phpizegrep: /usr/include/php/main/php.h: No such file or directorygrep: /usr/include/php/Zend/zend_modules.h: No such file or directorygrep: /usr/include/php/Zend/zend_extensions.h: No such file or directoryConfiguring for:PHP Api Version:Zend Module Api No:Zend Extension Api No:
3、配置编译信息
先确定php-config的位置,我的机器上是:/usr/local/bin/php-config
cent os./configure --with-php-config=/usr/local/bin/php-config --enable-http2 --enable-swoole-json --enable-swoole-curl --enable-opensslmac os 中指定openssl路径./configure --with-php-config=/usr/local/bin/php-config --enable-http2 --enable-swoole-json --enable-swoole-curl --enable-openssl --with-openssl-dir=/usr/local/Cellar/openssl@1.1/1.1.1h
4、编译并安装
make && make install
大功告成!
通过php --ri swoole查看下swoole的版本
xiongxudeMacBook-Pro:swoole-src-4.4.14 xmsite$ php --ri swooleswooleSwoole => enabledAuthor => Swoole Team <team@swoole.com>Version => 4.4.14Built => Jan 12 2020 00:33:27coroutine => enabledkqueue => enabledrwlock => enabledpcre => enabledzlib => 1.2.11brotli => E16777223/D16777223async_redis => enabledDirective => Local Value => Master Valueswoole.enable_coroutine => On => Onswoole.enable_library => On => Onswoole.enable_preemptive_scheduler => Off => Offswoole.display_errors => On => Onswoole.use_shortname => On => Onswoole.unixsock_buffer_size => 262144 => 262144
