php8.2 安装swoole扩展 (mac m1)

php8.2 安装swoole扩展 发现报错 此处记录

  1. 使用pecl安装
sudo  pecl install swoole
...
# 发现报错

/opt/homebrew/Cellar/[email protected]/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
  1. 试试源码编译安装呢
    下载源码地址
wget https://github.com/swoole/swoole-src/archive/refs/tags/v5.1.2.tar.gz

# 解压
tar zxvf swoole-src-5.1.2.tar.gz                                                             ✔  1035414:51:06
cd swoole-src-5.1.2 && \
phpize && \
./configure && \
sudo make && sudo make install

# 发现报同样错
/opt/homebrew/Cellar/[email protected]/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

着手解决这个异常

brew install pcre2
ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/[email protected]/8.2.15/include/php/ext/pcre/pcre2.h

重新执行1

安装成功

参考链接

swoole官方文档

博客

你可能感兴趣的:(swoole,macos,后端)