背景: ubuntu 更新时,选择,保留当前 php 版本,导致出现了 多个php 版本 ,phpinfo 显示的是 php7.1。在用 php -i 查看,发现,很多扩展打不开。

1. Ubuntu16.04中php如何切换版本

sudo update-alternatives --config php

选择 php7.3

2.停用 php7.1

sudo a2dismod php7.1
# Module php7.1 disabled.

3.重启 apache :

systemctl restart apache2

To activate the new configuration, you need to run:

systemctl restart apache2

4. 查看 phpinfo 时,是 7.3,并且,扩展没有报错。


ubuntu 16.04 + apache2 将php7.1 切换到 php7.3