卸载旧的PHP版本
## 因为我使用的是 Centos7.7版本, 默认提供了 PHP 5.4 , 所以需要先升级到 PHP 71. 设置 PHP 7 的 yum 源rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm## 等同于下面yum install epel-release -yrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm## 我们看一下我们可以安装的版本yum list php7*## 然后我们选择安装yum install php72w -y## 然后再安装一下 php 的扩展yum install php72w-common php72w-fpm php72w-opcachephp72w-gd php72w-mysqlnd php72w-mbstring php72w-pecl-redisphp72w-cliphp72w-pecl-memcached php72w-devel -y## 安装完成后, 我们来查看一下php -vPHP 7.2.27 (cli) (built: Jan 26 2020 15:49:49) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologieswith Zend OPcache v7.2.27, Copyright (c) 1999-2018, by Zend Technologies
安装准备
安装之前必须保证系统已经安装了以下软件
php-7.1或更高版本gcc-4.8或更高版本makeautoconfgccgcc-c++pcre-develphp-devel (对应PHP版本的)
源码安装
下载源码
下载地址 : https://gitee.com/swoole/swoole
编译安装
Swoole扩展是按照PHP标准扩展构建的。使用phpize来生成编译检测脚本,./configure来做编译配置检测,make进行编译,make install进行安装。
## 先去 https://gitee.com/swoole/swoole/tree/ 知道对应的版本## 我使用 https://gitee.com/swoole/swoole/tree/v4.4.10/## 需要先安装 wget 以及 unzip 命令yum install wget unzip -y## 链接地址需要自己去查找,[root ~]# cd /opt[root opt]# wget https://gitee.com/swoole/swoole/repository/archive/v4.4.10.zip[root opt]# unzip v4.4.10.zip[root opt]# ls | grep swooleswoole[root opt]# cd swoole[root swoole]# phpize[root swoole]# ./configure && make && make install## 然后找到 php.ini 文件, 然后新增一行,需要在 php.ini 中加入一行 extension=swoole.so 来启用 Swoole 扩展## 然后启动用 php-fpm 以及创建 index.php 文件<?phpphpinfo();?>## 配置虚拟主机来查看是否安装成功 或者使用 php -m 命令
