下载swoole源码swoole-src-4.2.5.zip,解压编译安装
unzip swoole-src-4.2.5.zip
cd swoole-src-4.2.5
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config
make
make install
修改/etc/php.ini文件,添加swoole扩展使用
extension=swoole.so
检查编译扩展是否有swoole
php -m |grep swoole
正常情况下会输出swoole
遇到问题: 1.mac系统没有安装Command_Line_Tools工具,我是先安装xcode再从官网https://developer.apple.com/download/more/ 下载文件 Command_Line_Tools_macOS_10.14_for_Xcode_10.1_Beta_2.dmg进行安装
2.编译swoole,依赖pcre正则库,直接通过brew进行安装 brew install pcre