简体   繁体   English

在 ubuntu 17.04 中安装 php 7.2 时出错

[英]Error while installing php 7.2 in ubuntu 17.04

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读取 state 信息...完成

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'

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 PHP from source.有关从源代码编译 PHP 的更多信息,请查看如何从源代码构建/编译 PHP

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

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

  1. Completely remove ALL versions of PHP完全删除所有版本的 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):在你的sources.list(位于/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:之后为系统上的 PHP 包配置 PPA:

     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:最后,使用以下选项之一安装符合您要求的 PHP:

    For installing PHP 7.2用于安装 PHP 7.2

     sudo apt install php7.2-cli

    For installing PHP 7.1用于安装 PHP 7.1

     sudo apt install php7.1-cli

In my case a newer php was installed (7.4), so i just replaced the command with the 7.4 versions在我的情况下,安装了更新的 php (7.4),所以我只是用 7.4 版本替换了命令

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

to know the version of php installed, use:要知道安装的 php 版本,请使用:

php --version

If you getting error like php7.2 php7.2-curl doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this.如果您收到类似php7.2 php7.2-curl没有可安装的候选者或找不到任何 package 或依赖项是php7.2-commonlibcurl3的错误,请执行此操作。 Remeber Change your package name as per your requirements记住根据您的要求更改您的 package 名称

You have to tackle in mature way.你必须以成熟的方式应对。 Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.安装aptitude这些ubuntu package管理器会找到所有的依赖,会一一安装。

apt-get install aptitude

Now you have to check if aptitude can download it or not if download it follow instructions现在你必须检查 aptitude 是否可以下载它是否按照说明下载

sudo aptitude install php7.2-curl

If you have gotten any error like this如果您遇到这样的错误

 E: Unable to locate package php7.2-curl E: Couldn't find any package by glob 'php7.2-curl'

Any type on error i'm not talking about proper these errors任何类型的错误我都不是在谈论正确的这些错误

Try to add php package again尝试再次添加 php package

sudo apt-add-repository ppa:ondrej/php

sudo apt-get update

Now try this command现在试试这个命令

sudo aptitude install php7.2-curl

Aptitude will ask you you want to keep current version of all dependencies Aptitude 会询问您是否要保留所有依赖项的当前版本

 The following actions will resolve these dependencies: Keep the following packages at their current version: 1) php7.2-curl [Not Installed] Accept this solution? [Y/n/q/?]

Type n then Enter输入n然后Enter

Aptitude will find all dependencies and ask you to install all package type Aptitude 将找到所有依赖项并要求您安装所有 package 类型

y

Again再次

y

Then然后

systemctl restart apache2

For centos of rhel对于rhel的centos

systemctl restart httpd

It will Not enabling PHP 7.2 FPM by default.默认情况下,它不会启用 PHP 7.2 FPM。 NOTICE: To enable PHP 7.2 FPM in Apache2 do注意:要在 Apache2 中启用 PHP 7.2 FPM,请执行

a2enmod proxy_fcgi setenvif

a2enconf php7.2-fpm

This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.此方法不仅适用于此错误,您还可以使用 php apache2 或 ubuntu 系统 ZEFE90A8E6036A7C86B70E88Z 解决方案找到任何一个。

Upvote if you find your solution

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM