该文章记录mac下编译安装swoole步骤 老生常谈 第一步下载swoole源码,解压,进入源码目录执行 phpize 。注意多个php版本别搞错了
iuu@iuudeMac-Studio swoole-src-5.1.1 % /opt/homebrew/opt/php@8.2/bin/phpize
Configuring for:
PHP Api Version: 20220829
Zend Module Api No: 20220829
Zend Extension Api No: 420220829
config.m4:359: warning: The macro 'AC_PROG_CC_C99' is obsolete.
config.m4:359: You should run autoupdate.
./lib/autoconf/c.m4:1662: AC_PROG_CC_C99 is expanded from...
config.m4:359: the top level
然后配置编译参数
./configure --with-php-config=/opt/homebrew/opt/php@8.2/bin/php-config --enable-openssl --with-openssl-dir=/opt/homebrew/Cellar/openssl@3/3.2.0_1 --enable-swoole-curl
然后配置编译
make && make install
M1 下会产生这个错误
/opt/homebrew/Cellar/php@8.2/8.2.15/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
^~~~~~~~~
1 error generated.
make: *** [ext-src/php_swoole.lo] Error 1
解决方式 (注意版本路径) 两个文件任选其一
ln -s /opt/homebrew/Cellar/pcre2/10.36/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.16/include/php/ext/pcre/pcre2.h
ln -s /opt/homebrew/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.16/include/php/ext/pcre/pcre2.h
清理make 缓存
make clean
然后配置编译
make && make install
成功之后,将swoole.so加入到php.ini中
# 找到自己的当前php版本的所在ini
php --ini
# 修改加入
[swoole]
extension = swoole.so
swoole.use_shortname = Off
# 查看是否安装成功
php -m
php --ri swoole
本文为北溟有鱼QAQ原创文章,转载无需和我联系,但请注明来自北溟有鱼QAQ https://www.amdzz.cn
最新评论