在 ubuntu 17.04 中安装 php 7.2 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50947291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:51:03  来源:igfitidea点击:

Error while installing php 7.2 in ubuntu 17.04

phpubuntu-17.04

提问by rawathemant

I got this error when run below command

运行以下命令时出现此错误

sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm   

Reading state information... Done

读取状态信息...完成

E: Unable to locate package php7.2
E: Couldn't find any package by glob 'php7.2'
E: Couldn't find any package by regex 'php7.2'
E: Unable to locate package php7.2-common
E: Couldn't find any package by glob 'php7.2-common'
E: Couldn't find any package by regex 'php7.2-common'
E: Unable to locate package php7.2-cli
E: Couldn't find any package by glob 'php7.2-cli'
E: Couldn't find any package by regex 'php7.2-cli'
E: Unable to locate package php7.2-fpm
E: Couldn't find any package by glob 'php7.2-fpm'
E: Couldn't find any package by regex 'php7.2-fpm'

回答by hassan

you need to manually add the ondrej PPA to be able to install PHP7.2 on Ubuntu 17

您需要手动添加 ondrej PPA 才能在 Ubuntu 17 上安装 PHP7.2

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2

Or by compiling it from source by cloning the git repository, checking out to the version that you want, make & make install

或者通过克隆 git 存储库从源代码编译它,检查到您想要的版本,make & make install

for more informations about compiling PHP from source check out how to build/compile PHPfrom source.

有关从源代码编译 PHP 的更多信息,请查看如何从源代码构建/编译 PHP

回答by Roger Mungo

I had a similar problem. This page helped me resolve it. https://tecadmin.net/install-php-debian-9-stretch/

我有一个类似的问题。这个页面帮我解决了这个问题。 https://tecadmin.net/install-php-debian-9-stretch/

specifically, running these commands prior to the php install

具体来说,在安装 php 之前运行这些命令

sudo apt install ca-certificates apt-transport-https

sudo apt install ca-certificates apt-transport-https

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

回答by Hany Afifi

  1. Completely remove ALL versions of PHP

    sudo apt-get purge 'php*' 
    
  2. Force update from unsigned repository:

    Add this option in your sources.list (located at /etc/apt/sources.list):

    deb [trusted=yes] https://deb.sury.org/ stretch main 
    
  3. Upgrade the current packages to the latest version:

    sudo apt update  
    
    sudo apt upgrade  
    
  4. Install the required packages first on your system:

    sudo apt install ca-certificates apt-transport-https  
    

    Then import packages signing key:

    wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -  
    

    After that configure PPA for the PHP packages on your system:

    echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list 
    
  5. Lastly, use one of the below options to install PHP of your requirements:

    For installing PHP 7.2

    sudo apt install php7.2-cli 
    

    For installing PHP 7.1

    sudo apt install php7.1-cli 
    
  1. 完全删除所有版本的 PHP

    sudo apt-get purge 'php*' 
    
  2. 从未签名的存储库强制更新:

    在你的sources.list(位于/etc/apt/sources.list)中添加这个选项:

    deb [trusted=yes] https://deb.sury.org/ stretch main 
    
  3. 将当前包升级到最新版本:

    sudo apt update  
    
    sudo apt upgrade  
    
  4. 首先在您的系统上安装所需的软件包:

    sudo apt install ca-certificates apt-transport-https  
    

    然后导入包签名密钥:

    wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -  
    

    之后为系统上的 PHP 包配置 PPA:

    echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list 
    
  5. 最后,使用以下选项之一安装符合您要求的 PHP:

    用于安装 PHP 7.2

    sudo apt install php7.2-cli 
    

    用于安装 PHP 7.1

    sudo apt install php7.1-cli