Error while installing php 7.2 in ubuntu 17.04
Asked Answered
S

5

24

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'
Sphery answered 20/6, 2018 at 11:35 Comment(1)
you can see this: This commands helps me:Meda
W
47

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.

Willumsen answered 20/6, 2018 at 11:43 Comment(12)
what's response that you are getting? and are you sure that the apt-get update command does not produce any errors/warngings?Willumsen
May be issue with the ubuntu version. I did that installation successfully on ubuntu 16.04 but now i'm trying it on 17.04.Sphery
what is the response of executing sudo apt-get install php7.2 ?Willumsen
Reading package lists... Done Building dependency tree 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'Sphery
what is the output of the following command : grep -rn 'ondrej/php' /etc/apt/sources.list /etc/apt/sources.list.d/*Willumsen
Let us continue this discussion in chat.Sphery
I followed same step but still not installed.getting same error.I am getting error while update apt-get update. error like unable to find expected entry stable/source/sources . I am using ubuntu 17.04 and trying to install php7.3. getting error as unable to find package 7.3Muhammadan
@Willumsen I followed that command but still not installed. ubuntu@ip-172-31-13-22:~$ sudo apt-get install php7.2 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php7.2 E: Couldn't find any package by regex 'php7.2' ubuntu@ip-172-31-13-22:~$Oxazine
@Oxazine are you sure that you had added the repository successfully ?Willumsen
@Willumsen I'am using VM with vagrant and I encounter the same problem after successful repository add and update. Here is the error that I get : vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get install php7.3 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php7.3 E: Couldn't find any package by regex 'php7.3'Multiversity
same answer everywhere but never work :(Invective
@AamirAfridi what is the error you are getting?Willumsen
E
23

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

Exit answered 17/9, 2018 at 22:58 Comment(3)
Saved my life. Thanks!!Rouvin
getting this on apt-get update W: Failed to fetch https://packages.sury.org/php/dists/stretch/main/binary-amd64/Packages gnutls_handshake() failed: Handshake failedOfficialdom
Worked for me in Docker with Ubuntu 16.04 image. Remember to remove sudo (inside Dockerfile)Spinescent
F
0
  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 
    
Frigg answered 23/10, 2019 at 12:53 Comment(1)
Why purge all existing php before updating? This is just asking for trouble. Install the new version and simply switch to using that instead. Remove old PHP once you are comfortably on the newer version.Nowlin
C
0

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
Columelliform answered 4/10, 2020 at 13:53 Comment(0)
R
0

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
Rhyme answered 9/10, 2021 at 20:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.