Linux环境下安装Swoole

一、先安装依赖

yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

二、安装php7

如果之前就有PHP但版本低于7就先卸掉(swoole最新版只支持PHP7.0及以上版本)

yum remove php* php-common

安装apache服务器(有了就跳过)

yum install httpd

rpm安装php7.1相应的yum源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装php7

yum install php71w php71w-opoache php71--cli  php71w-devel php71w-fpm

三、安装swoole

安装Git

yum install git

clone swoole源码

git clone https://github.com/swoole/swoole-src.git

解压编译

cd swoole-src
phpize
./configure
make && make install

如果跳过了第一步安装依赖,这一步就很有可能有如下报错

make: *** No targets specified and no makefile found. Stop.   //那就只能安装第一步的依赖之后,再进行这一步了

四、修改php.ini配置文件(加在前面没有注释符的任意一行)

extension_dir = "/usr/lib64/php/modules/"
extension=swoole.so

五、重启服务检查扩展安装情况

service php-fpm restart
service httpd restart
php -m

你可能感兴趣的:(Linux环境下安装Swoole)