1.安装swoole
arch -arm64 pecl install swoole (ps:默认为现在版本为5.1.1)
若指定版本
arch -arm64 pecl install https://pecl.php.net/get/swoole-4.6.7.tgz
(ps:连接为 pecl.php.net 搜索swoole指定版本的后的连接)
1.1 Connection to `ssl://pecl.php.net:443' failed:
查找openssl 的证书信息
php -r "print_r(openssl_get_cert_locations());"
[default_cert_file] => /opt/homebrew/etc/openssl@3/cert.pem
查看该证书是否存在,若未存在,则去下载证书 https://curl.se/ca/cacert.pem
若存在,则查看地址是否正确,或者下载证书替换
1.2 fatal error: 'openssl/ssl.h' file not found
在编译的时候加上参数:--with-openssl-dir=/opt/homebrew/opt/openssl@3
openssl-dir 的地址查看:brew --prefix openssl
1.3 fatal error: 'pcre2.h' file not found
检查pcre2是否安装:brew --prefix pcre2
若未安装,则先安装 brew install pcre2
查看php拓展安装路径:/opt/homebrew/Cellar/php@7.4/7.4.33_5/include/php/ext
做软连接:
ln -s /opt/homebrew/opt/pcre2/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.33_5/include/php/ext/pcre/pcre2.h
安装完成后,使用
php -m|grep swoole 查看是否安装成功
php -ri swoole 查看swoole模块的配置信息