Swoole 初体验之安装篇
Homestead 安装swoole
代码语言:javascript复制sudo apt-get install php7-dev
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
phpize
./configure --with-php-config=/usr/bin/php-config7.2
make && make install
编辑 php.in
i 文件,添加 swoole
扩展
代码语言:javascript复制查找不到 php.ini 文件在哪?怕修改错?试试下面的命令吧
php -i | grep php.ini
下面就是 php.ini 文件所在的路径
代码语言:javascript复制Loaded Configuration File => /etc/php/7.2/cli/php.ini
修改php.ini 添加extension=swoole
sudo vim /etc/php/7.2/cli/php.ini
extension=swoole
接下来看下是否安装成功,看下是否列出 swoole
扩展
php -m
Mac 安装 swoole
代码语言:javascript复制brew install php@7.3
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
phpize
./configure
make && make install
修改php.ini 添加extension=swoole
sudo vim /usr/local/etc/php/7.3/php.ini
extension=swoole
Mac 安装可能会出现如下错误:
代码语言:javascript复制grep: /usr/local/Cellar/php/7.3.0/include/php/main/php.h: No such file or directory
grep: /usr/local/Cellar/php/7.3.0/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/local/Cellar/php/7.3.0/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
./php_swoole.h:25:10: fatal error: 'php.h' file not found
#include "php.h"
网上说是执行下列语句即可解决
代码语言:javascript复制sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include /usr/include
接着会出现:
代码语言:javascript复制ln: /usr/iclude: Operation not permitted
出现以上问题这是因为高版本的 Mac 存在一种 Rootless 机制
关闭Rootless
重启电脑 按住Command R 进入恢复模式,打开终端输入以下内容 csrutil disable 开启 csrutil enable
之后重新编译安装即可