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
相关推荐
JaguarJack17 小时前
推荐 PHP 属性(Attributes) 简洁读取 API 扩展包
后端·php·服务端
BingoGo17 小时前
推荐 PHP 属性(Attributes) 简洁读取 API 扩展包
php
蝎子莱莱爱打怪2 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
崔小汤呀2 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端
何中应2 天前
vi编辑器使用
linux·后端·操作系统
何中应2 天前
Linux进程无法被kill
linux·后端·操作系统
何中应2 天前
rm-rf /命令操作介绍
linux·后端·操作系统
何中应2 天前
Linux常用命令
linux·操作系统
葛立国2 天前
从 / 和 /dev 说起:Linux 文件系统与挂载点一文理清
linux
JaguarJack2 天前
告别 Laravel 缓慢的 Blade!Livewire Blaze 来了,为你的 Laravel 性能提速
后端·php·laravel