swoole4.4安装使用

swoole文档:https://wiki.swoole.com/#/environment

官方github源码包的下载地址,根据自己的需要下载,https://github.com/swoole/swoole-src/releases

1.先下载官方扩展包,解压

[root@iz8vbjfugmkid4cknmtq8bz ~]#wget https://codeload.github.com/swoole/swoole-src/zip/master
[root@iz8vbjfugmkid4cknmtq8bz ~]# unzip master
[root@iz8vbjfugmkid4cknmtq8bz ~]# cd swoole-src-master/

  

2.使用phpize安装

[root@iz8vbjfugmkid4cknmtq8bz swoole-src-master]# whereis phpize  #查看phpize路径,如果没有需要先安装phpize
phpize: /usr/bin/phpize
[root@iz8vbjfugmkid4cknmtq8bz swoole-src-master]# /usr/bin/phpize  #在源码包目录下执行phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@iz8vbjfugmkid4cknmtq8bz swoole-src-master]# ./configure --with-php-config=/usr/local/php/bin/php-config #执行编译检查
[root@iz8vbjfugmkid4cknmtq8bz swoole-src-master]# make
[root@iz8vbjfugmkid4cknmtq8bz swoole-src-master]# make install 
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
Installing header files:          /usr/local/php/include/php/

编译安装成功后,会显示出扩展的安装路径

修改PHP配置文件加入swoole扩展

vim /usr/local/php/etc/php.ini
extension=swoole.so

重启php-fpm生效
输入php --ri swoole 查看swoole版本

原文地址:https://www.cnblogs.com/cxscode/p/13158213.html