Question

Unable to locate package php7.2 Ubuntu 20.04

We are unable to install the php7.2 and php7.1 version in the ubuntu 20.04. Currently we are using php7.4 and we need the php7.2 also

When we tried to install the php7.2 below commands were not successful in the digital ocean.

downgrade PHP version to 7.2

apt 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 glob ‘php7.2’

sudo apt-add-repository ppa:ondrej/php

sudo apt update

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

sudo apt install -y php7.2-mysql php7.2-dom php7.2-simplexml php7.2-ssh2 php7.2-xml php7.2-xmlreader php7.2-curl  php7.2-exif  php7.2-ftp php7.2-gd  php7.2-iconv php7.2-imagick php7.2-json  php7.2-mbstring php7.2-posix php7.2-sockets php7.2-tokenizer

sudo apt install -y php7.2-mysqli php7.2-pdo  php7.2-sqlite3 php7.2-ctype php7.2-fileinfo php7.2-zip php7.2-exif

Let us know the solutions for this asap.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hello,

I just tested this on a fresh new Ubuntu 20.04 Droplet and I was able to install PHP 7.2 after running the following commands:

  • Update your repositories:
sudo apt update
  • Then add the Ondrej PHP repository:
sudo apt-add-repository ppa:ondrej/php
  • Run apt update again:
sudo apt update
  • Finally install PHP 7.2:
sudo apt install -y php7.2 php7.2-cli php7.2-common php7.2-fpm

If it still does not work, can you share the output of the following command here:

grep -rn 'ondrej/php' /etc/apt/sources.list /etc/apt/sources.list.d/*

Let me know how it goes! Best, Bobby

It looks like that php7.2-fpm is not available for Ubuntu 20.10

As per the @bobbyiliev suggestion i have created the new droplets and configured ubuntu 21.04 with php7.2 without any issues.

Thanks @bobbyiliev for your support.