win10 开启 liunx 子系统 安装 swoole
使用BashOnWindows为Ubuntu
修改apt-get源文件(/etc/apt/sources.list)
- 备份
cd /etc/apt/
sudo cp sources.list sources.list.bak
- 获取版本号并修改sources.list(我的版本号为bionic)
// 获取版本号:bionic
lsb_release -c
Codename: bionic
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
- 更新
sudo apt-get update
安装swoole
apt-get install php7.2 php7.2-curl php7.2-gd php7.2-gmp php7.2-json php7.2-mysql php7.2-opcache php7.2-readline php7.2-sqlite3 php7.2-tidy php7.2-xml php7.2-bcmath php7.2-bz2 php7.2-intl php7.2-mbstring php7.2-mcrypt php7.2-soap php7.2-xsl php7.2-zip
pecl install swoole
echo 'extension=swoole.so' >> /etc/php/7.2/mods-available/swoole.ini
cd /etc/php/7.2/cli/conf.d/ && ln -s ../../mods-available/swoole.ini 20-swoole.ini
检查swoole是否安装完成
php --ri swoole
Liunx(Centos) 编译安装 Swoole
更新yum
yum update
下载并解压安装swoole
wget https://github.com/swoole/swoole-src/archive/v4.4.16.tar.gz
tar -zxf v4.4.16.tar.gz
cd swoole-src-4.4.16/
phpize
./configure // 编译
maek install // 安装
修改php.ini配置
// PS : 可以使用 php --ini 来定位到 php.ini 的绝对路径
vim /www/server/php/72/etc/php.ini
// 添加扩展
extension=swoole.so
// 查看是否安装完成
php -m