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
相关推荐
旖旎夜光1 天前
Linux(13)(中)
linux·网络
威迪斯特1 天前
CentOS图形化操作界面:理论解析与实践指南
linux·运维·centos·组件·图形化·桌面·xserver
一方热衷.1 天前
在线安装对应版本NVIDIA驱动
linux·运维·服务器
独自归家的兔1 天前
ubuntu系统安装dbswitch教程 - 备份本地数据到远程服务器
linux·运维·ubuntu
ONE_SIX_MIX1 天前
ubuntu 24.04 用rdp连接,桌面黑屏问题,解决
linux·运维·ubuntu
龙飞051 天前
Systemd -systemctl - journalctl 速查表:服务管理 + 日志排障
linux·运维·前端·chrome·systemctl·journalctl
*小海豚*1 天前
在linux服务器上DNS正常,但是java应用调用第三方解析域名报错
java·linux·服务器
June`1 天前
muduo项目排查错误+测试
linux·c++·github·muduo网络库
春日见1 天前
如何创建一个PR
运维·开发语言·windows·git·docker·容器
DARLING Zero two♡1 天前
告别 Docker 命令行!Portainer+cpolar 让容器管理从局域网走向公网
运维·docker·容器