2月
02
直接开始
# 方式一
sudo pecl channel-update pecl.php.net
sudo pecl install swoole
# 方式二
# 官网 https://wiki.swoole.com/#/environment
# pecl https://pecl.php.net/package/swoole
cd /usr/local/src
sudo wget https://pecl.php.net/get/swoole-4.6.2.tgz
sudo tar -xzvf swoole-4.6.2.tgz
cd swoole-4.6.2
sudo phpize
sudo ./configure \
--enable-openssl \
--enable-http2
# 支持更多可以看文档
./configure \
--enable-openssl \
--enable-http2 \
--enable-swoole-json \
--enable-swoole-curl
sudo make && make install
sudo make test
# 找到扩展存放位置
php -i|grep extension_dir
/usr/lib/php/20190902
sudo cp /usr/local/src/swoole-4.6.2/modules/swoole.so ./swoole.so
# 然后安装下边的方式配置和重启即可。
# 找 php 版本,发现是 7.4
php -v
sudo vim /etc/php/7.4/mods-available/swoole.ini
# php 扩展安装位置
php -i|grep extension_dir
# 写入下边内容
extension=swoole.so
# 创建软链
cd /etc/php/7.4/cli/conf.d
sudo ln -s /etc/php/7.4/mods-available/swoole.ini ./20-swoole.ini
# 重启
sudo service php7.4-fpm restart
# 查看
php --ri swoole
php -i |grep swoole