我尝试在 Chromebook 上激活开发者模式时在我设置的 Linux 中安装 php。但是,尽管尝试了两种不同的方法,但不知何故它似乎确实有效:
-
按照链接操作,但我得到了这个输出:
njtmendes@penguin:~$ sudo apt install -y php7.4 php7.4-cli php7.4-common Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php7.4 E: Couldn't find any package by glob 'php7.4' E: Couldn't find any package by regex 'php7.4' E: Unable to locate package php7.4-cli E: Couldn't find any package by glob 'php7.4-cli' E: Couldn't find any package by regex 'php7.4-cli' E: Unable to locate package php7.4-common E: Couldn't find any package by glob 'php7.4-common' E: Couldn't find any package by regex 'php7.4-common' njtmendes@penguin:~$ ^C njtmendes@penguin:~$ php -v -bash: php: command not found njtmendes@penguin:~$ ^C njtmendes@penguin:~$
https://www.cloudbooklet.com/install-php-7-4-on-ubuntu/ 我尝试了上述解决方案,希望能够针对 Debiam 进行调整,但仍然不起作用
输出:
[6:16 pm, 28/04/2020] Nuno Da Elizabeth: njtmendes@penguin:~$ sudo add-apt-repository ppa:ondrej/php Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided. Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa You can get more information about the packages at https://deb.sury.org BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting CAVEATS: 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman 2. If you are using apache2, you are advised to add ppa:ondrej/apache2 3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline or ppa:ondrej/nginx PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/ WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround: # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php More info: https://launchpad.net/~ondrej/+archive/ubuntu/php Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keybox '/tmp/tmpmbr9q9y5/pubring.gpg' created gpg: /tmp/tmpmbr9q9y5/trustdb.gpg: trustdb created gpg: key 4F4EA0AAE5267A6C: public key "Launchpad PPA for Ondřej Surý" imported gpg: Total number processed: 1 gpg: imported: 1 gpg: no valid OpenPGP data found. [6:17 pm, 28/04/2020] Helio: cool [6:18 pm, 28/04/2020] Helio: sudo apt-get update [6:18 pm, 28/04/2020] Nuno Da Elizabeth: njtmendes@penguin:~$ sudo apt-get update Hit:1 http://packages.microsoft.com/repos/vscode stable InRelease Ign:2 http://ppa.launchpad.net/ondrej/php/ubuntu groovy InRelease Err:3 http://ppa.launchpad.net/ondrej/php/ubuntu groovy Release 404 Not Found [IP: 2001:67c:1560:8008::15 80] Get:4 https://packages.sury.org/php stretch InRelease [6,760 B] Hit:5 https://deb.debian.org/debian buster InRelease Hit:6 https://deb.debian.org/debian-security buster/updates InRelease Ign:7 https://storage.googleapis.com/cros-packages/81 buster InRelease Hit:8 https://storage.googleapis.com/cros-packages/81 buster Release Get:9 https://packages.sury.org/php stretch/main amd64 Packages [136 kB] Reading package lists... Done E: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu groovy Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
`apt update` 的输出
njtmendes@penguin:~$ sudo apt update Hit:1 http://packages.microsoft.com/repos/vscode stable InRelease Hit:2 https://deb.debian.org/debian buster InRelease Hit:3 https://deb.debian.org/debian-security buster/updates InRelease Ign:4 https://storage.googleapis.com/cros-packages/81 buster InRelease Hit:5 https://storage.googleapis.com/cros-packages/81 buster Release Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date.
无法安装 PHP 是相当令人沮丧的。
答案1
看来您没有按照第一个链接中的指示成功将 PPA(附加存储库)添加到容器中。
该网站上的说明表明您需要知道您正在运行哪个版本的 Debian。在许多 Linux 发行版上,最快的方法是
cat /etc/os-release
根据您的输出,apt update
我怀疑您正在运行 Buster (Debian 9)
要获取其他 APT 存储库,请按照以下步骤操作
sudo apt update
sudo apt install -y curl wget gnupg2 ca-certificates lsb-release apt-transport-https
wget https://packages.sury.org/php/apt.gpg
sudo apt-key add apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list
sudo apt update
然后你就可以安装你想要的 PHP 版本
sudo apt -y install php7.4 php7.4-cli php7.4-common
php -v
PHP 7.4.6 (cli) (built: May 14 2020 10:03:28) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies