1. 下载7.4
1、添加php ppa
1 2 3 4 5 |
step1: sudo apt-get update step2: sudo apt install software-properties-common step3: sudo add-apt-repository ppa:ondrej/php |
2、安装php7.4
1 |
sudo apt install php7.4 |
2. 切换版本
- sudo update-alternatives –config php ,选择对应Selection的列值就可以
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
root@iZbp1apb7njwhoh5kjwzh0Z:~# sudo 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 root@iZbp1apb7njwhoh5kjwzh0Z:~# php -v PHP 7.4.33 (cli) (built: Sep 2 2023 08:03:46) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies |