1

我想安装特定版本的 php,我写了这个命令sudo apt-get install php7.2,它显示如下

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'php7.2-common' for regex 'php7.2'
Note, selecting 'php7.2-sodium' for regex 'php7.2'
Note, selecting 'libapache2-mod-php7.2' for regex 'php7.2'
Note, selecting 'php7.2-thrift' for regex 'php7.2'
0 upgraded, 0 newly installed, 0 to remove and 235 not upgraded.

在此之后,当我想知道 php 的版本时,我运行php -v我收到以下错误

Command 'php' not found, but can be installed with: sudo apt install php7.4-cli # version 7.4.16-1ubuntu2.1, or sudo apt install php-cli # version 2:7.4+76ubuntu1

4

2 回答 2

1

尝试以下步骤:

1:添加 Ondrej 的 PPA,其中包含 PHP 7.2 包:

sudo add-apt-repository ppa:ondrej/php

2:更新:

sudo apt update

3:安装PHP 7.2

sudo apt install php7.2

4:选择PHP的标准版本

sudo update-alternatives --set php /usr/bin/php7.2

5:重启Apache2:

sudo systemctl restart apache2
于 2021-08-26T12:52:28.740 回答
0

运行以下命令它将起作用

sudo apt update
sudo apt upgrade

sudo apt install ca-certificates apt-transport-https

wget -q https://packages.sury.org/php/apt.gpg -- I sudo apt-key add echo "deb https://packages.sury.org/php/stretch

main" | sudo tee /etc/apt/sources.list.d/php.list 
sudo apt update

sudo apt install php7.2
于 2021-08-26T12:54:30.047 回答