Linux多PHP如何切换系统默认PHP版本

复制代码
PHP Warning:  PHP Startup: igbinary: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20180731
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: redis: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20180731
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: SourceGuardian: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20180731
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'swoole.so' (tried: /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/swoole.so (/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/swoole.so: cannot open shared object file: No such file or directory), /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/swoole.so.so (/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/swoole.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: fileinfo: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20180731
These options need to match
 in Unknown on line 0
Workerman[think] stop 
Workerman[think] is stopping ...
Workerman[think] stop success
You have new mail in /var/spool/mail/root,检查下提示,这是什么问题

提示如上错误,说明PHP 扩展版本与当前 PHP 版本不兼容,核心错误信息如下:

bash 复制代码
Module compiled with module API=20190902
PHP    compiled with module API=20180731
These options need to match

问题原因

  • module API=20180731 对应的是 PHP 7.3

  • module API=20190902 对应的是 PHP 7.4

那么如何切换PHP版本

bash 复制代码
# 1. 删除旧链接
rm -f /usr/bin/php

# 2. 创建新链接
ln -s /www/server/php/74/bin/php /usr/bin/php

# 3. 验证
php -v
相关推荐
damoluomu3 天前
挑 PHP CMS 之前,先学会看它的协议
php
未济3 天前
linux 配置环境变量
linux
傲世仙尊3 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.3 天前
进程间通信
linux
AI职业加油站3 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
Liuqy-053 天前
Linux IO编程——静态库、动态库
linux
此冬歌咏3 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
彧azz3 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅3 天前
linux(8) 软硬链接
linux·运维·服务器