服务器环境:PHP Version 7.2.25
为了使用wss协议,需要安装swoole的openssl
决定重新编译安装swoole,过程中遇到以下问题,在执行make命令时报错如下
error: #error "require PHP version 7.1 or later"

swoole要求
php版本>=7.1
,执行命令php -v
输出的7.2.25
,按理说不应该报错,这种情况一般都是旧php版本遗留的文件导致的
查看php-config信息
执行命令find / -name php-config
可以看到有多个php-config文件

分别执行两个文件查看输出的版本信息

linux默认执行的是/usr/bin/php-config,也就是PHP5.4.16,基本能确定问题就是出在这里,PHP5.4.16是系统默认安装的
解决办法:直接把
php5.4
的删掉,php7.2
复制过去
phpize 也会出现版本问题
解决方法同上,先查看是否有多个phpize
执行命令phpize
,看输出的版本号是不是和你phpinfo()
中的版本对应,不一样的话解决方法同上.


重新编译安装swoole,在swoole源码目录下依次执行
make clean
phpize
./configure --enable-openssl --enable-http2
make
编译成功

最后执行
make install

记下扩展安装的路径,修改php.ini添加扩展

保存退出,重启php-fpm(命令
service php-fpm restart
)查看phpinfo();

搞定!
网友评论