ubuntu下多版本PHP切换:
root@k8s-server:$ update-alternatives --config php
There are 2 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php8.1 81 auto mode
* 1 /usr/bin/php7.4 74 manual mode
2 /usr/bin/php8.1 81 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in manual mode
然后查看/usr/bin/php,其对应的软连接为 /etc/alternatives/php,说明是可选择的
/usr/bin/php---->/etc/alternatives/php
查看/etc/alternatives/php,发现又会指向真正设置的版本:
$ ls -l /etc/alternatives/php
lrwxrwxrwx 1 root root 15 12月 12 09:39 /etc/alternatives/php -> /usr/bin/php7.4
或者通过 readlink 命令查看:
$ readlink -f /etc/alternatives/php
/usr/bin/php7.4
不同版本php状态查看:
$ systemctl status php8.1-fpm
$ systemctl status php7.4-fpm
