Error while installing php 7.2 in ubuntu 17.04

68.9k Views Asked by At

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'
5

There are 5 best solutions below

10
hassan On BEST ANSWER

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 the source by cloning the git repository, checking out the version that you want, make & make install

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

3
Roger Mungo On

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
Hany Afifi On
  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 
    
0
Dany Balian On

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
0
CodeWithRonny On

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