简体   繁体   中英

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

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

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

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

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

specifically, running these commands prior to the php install

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

     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

In my case a newer php was installed (7.4), so i just replaced the command with the 7.4 versions

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

to know the version of php installed, use:

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. Remeber Change your package name as per your requirements

You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.

apt-get install aptitude

Now you have to check if aptitude can download it or not if download it follow instructions

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

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

 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

Aptitude will find all dependencies and ask you to install all package type

y

Again

y

Then

systemctl restart apache2

For centos of rhel

systemctl restart httpd

It will Not enabling PHP 7.2 FPM by default. NOTICE: To enable PHP 7.2 FPM in Apache2 do

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.

Upvote if you find your solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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