在Mac系统上安装swoole扩展有以下几种方法:
pecl install swoole
brew install swoole
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
git checkout 4.8.x
phpize
./configure
make && make install
安装完成后,在php.ini中添加swoole.so的路径,重启php-fpm即可:
php --ini
extension="swoole.so"
这样就可以在PHP 8环境下成功安装swoole扩展了。
/opt/homebrew/Cellar/php@8.1/8.1.23/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/include/pcre2.h /opt/homebrew/Cellar/php@8.1/8.1.23/include/php/ext/pcre/pcre2.h