无法在 ubuntu 上安装 php 7.4,但实际上并未安装?

无法在 ubuntu 上安装 php 7.4,但实际上并未安装?

我正在尝试将 nextcloud 从 v17 升级到 18。我需要升级我的 php 版本。

描述:Ubuntu 16.04.7 LTS

php-v 命令

PHP 7.1.33-37+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May  1 2021 11:51:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33-37+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

更新替代方案——config php

There is only one alternative in link group php (providing /usr/bin/php): /usr/bin/php7.1
Nothing to configure.

apt 安装 php7.4

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.4-cli' for regex 'php7.4'
Note, selecting 'php7.4-ffi' for regex 'php7.4'
Note, selecting 'php7.4-ftp' for regex 'php7.4'
Note, selecting 'php7.4-imagick' for regex 'php7.4'
Note, selecting 'php7.4-sysvmsg' for regex 'php7.4'
Note, selecting 'php7.4-json' for regex 'php7.4'
Note, selecting 'php7.4-phar' for regex 'php7.4'
Note, selecting 'php7.4-tokenizer' for regex 'php7.4'
Note, selecting 'php7.4-igbinary' for regex 'php7.4'
Note, selecting 'php7.4-shmop' for regex 'php7.4'
Note, selecting 'php7.4-sysvsem' for regex 'php7.4'
Note, selecting 'php7.4-sysvshm' for regex 'php7.4'
Note, selecting 'php7.4-apcu-bc' for regex 'php7.4'
Note, selecting 'php7.4-pdo' for regex 'php7.4'
Note, selecting 'php7.4-sockets' for regex 'php7.4'
Note, selecting 'php7.4-ctype' for regex 'php7.4'
Note, selecting 'php7.4-calendar' for regex 'php7.4'
Note, selecting 'php7.4-fileinfo' for regex 'php7.4'
Note, selecting 'php7.4-redis' for regex 'php7.4'
Note, selecting 'php7.4-opcache' for regex 'php7.4'
Note, selecting 'php7.4-readline' for regex 'php7.4'
Note, selecting 'php7.4-apcu' for regex 'php7.4'
Note, selecting 'php7.4-exif' for regex 'php7.4'
Note, selecting 'php7.4-smbclient' for regex 'php7.4'
Note, selecting 'php7.4-common' for regex 'php7.4'
Note, selecting 'php7.4-posix' for regex 'php7.4'
Note, selecting 'php7.4-iconv' for regex 'php7.4'
Note, selecting 'libapache2-mod-php7.4' for regex 'php7.4'
Note, selecting 'php7.4-gettext' for regex 'php7.4'
Note, selecting 'php7.4-common' instead of 'php7.4-calendar'
Note, selecting 'php7.4-common' instead of 'php7.4-ctype'
Note, selecting 'php7.4-common' instead of 'php7.4-exif'
Note, selecting 'php7.4-common' instead of 'php7.4-ffi'
Note, selecting 'php7.4-common' instead of 'php7.4-fileinfo'
Note, selecting 'php7.4-common' instead of 'php7.4-ftp'
Note, selecting 'php7.4-common' instead of 'php7.4-gettext'
Note, selecting 'php7.4-common' instead of 'php7.4-iconv'
Note, selecting 'php7.4-common' instead of 'php7.4-pdo'
Note, selecting 'php7.4-common' instead of 'php7.4-phar'
Note, selecting 'php7.4-common' instead of 'php7.4-posix'
Note, selecting 'php7.4-common' instead of 'php7.4-shmop'
Note, selecting 'php7.4-common' instead of 'php7.4-sockets'
Note, selecting 'php7.4-common' instead of 'php7.4-sysvmsg'
Note, selecting 'php7.4-common' instead of 'php7.4-sysvsem'
Note, selecting 'php7.4-common' instead of 'php7.4-sysvshm'
Note, selecting 'php7.4-common' instead of 'php7.4-tokenizer'
php7.4-common is already the newest version (7.4.18-2+ubuntu16.04.1+deb.sury.org+1).
php7.4-apcu-bc is already the newest version (1.0.5-13+ubuntu16.04.1+deb.sury.org+1).
php7.4-igbinary is already the newest version (3.2.1+2.0.8-6+ubuntu16.04.1+deb.sury.org+1).
php7.4-apcu is already the newest version (5.1.19+4.0.11-7+ubuntu16.04.1+deb.sury.org+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

apt 安装 php7.3

apt install php7.3-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.3-common is already the newest version (7.3.28-1+ubuntu16.04.1+deb.sury.org+1).

apt 安装 php7.2

apt install php7.2-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.2-common is already the newest version (7.2.34-21+ubuntu16.04.1+deb.sury.org+1).

/usr/bin 中的 grep -i *php*

grep -i *php*
Binary file php7.0 matches
Binary file php7.1 matches
Binary file php7.4 matches
Binary file php8.0 matches

答案1

您可能需要在 .htaccess 中使用 addhandler 来指定该文件夹正在使用哪个版本的 PHP。

https://stackoverflow.com/questions/12561203/how-to-change-php-version-in-htaccess-in-server

相关内容