一、MAC安装swoole命令
pecl install swoole
二、解决ssl.h not found
如果报错ssl.h not found,解决方法如下:
pecl install swoole
enable sockets supports? [no]: yes
enable openssi support? [no]: yes --with-openssL-dir=/opt/homebrew/opt/openssl
其中的/opt/homebrew/opt/openssl改为你openssl的目录,请确认好。
三、解决pcre2.h not found
1、先安装pcre2
brew install pcre2
2、pcre软连接
ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/php@8.1/8.1.27_1/include/php/ext/pcre/pcre2.h
其中/opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h和/opt/homebrew/Cellar/php@8.1/8.1.27_1/include/php/ext/pcre/pcre2.h改为你的目录,请确认好。
四、确认pcre软连接是否成功
进入/opt/homebrew/Cellar/php@8.1/8.1.27_1/include/php/ext/pcre目录,
cd /opt/homebrew/Cellar/php@8.1/8.1.27_1/include/php/ext/pcre
看这个目录是否存在pcre2.h
ls
五、解决了上述错误后,重新安装swoole
pecl install swoole
等待安装,出现以下证明安装成功了
六、验证是否成功安装和启用swoole
php -m | grep swoole
执行以上命令,输出swoole,则证明已成功启用。