Unable to locate package php cli

I'm installing a LAMP stack on an Ubuntu instance in Google Compute Engine. I'm following the instructions at https://cloud.google.com/community/tutorials/setting-up-lamp where I'm instructed to enter sudo apt-get install apache2 php libapache2-mod-php

When I press Enter, I get this message: Reading package lists... Done Building dependency tree
Reading state information... Done E: Unable to locate package php E: Unable to locate package libapache2-mod-php

Apparently Apache was installed because I can browse the page, but php and libapache2-mod-php are not found. Have the names been changed for these packages?

asked Jul 20, 2017 at 16:46

1

The ubuntu package is called php7.0

apt-get install php7.0

You may also want to use

apt-get install libapache2-mod-php7.0

In the future, you can check https://packages.ubuntu.com or run

apt-cache search php

answered Jul 20, 2017 at 17:26

Unable to locate package php cli

Ben M.Ben M.

1715 bronze badges

Packages names can diverge with ubuntu version. You can locate php packages names with a search command:

apt-cache search php

Be sure have an updated packages list before :

apt-get update

answered Jul 20, 2017 at 17:06

I'm actually setting up my vagrant vm (trusty-64, Ubuntu distribution v14.04) and encountered an issue during the installation of all ppa:ondrej/php packages.

I tried the default way to install php...

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install php7.3

But it still has this issue:

E: Unable to locate package php7.3
E: Couldn't find any package by regex 'php7.3'

It seems he's ignoring the added repository (it's not listed in apt-get update) but the command seems fine:

gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

Actually, i have no clue whats wrong. Maybe someone has an idea and can explain it? Thanks a lot.

UPDATE:

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.6 LTS
Release:        14.04
Codename:       trusty

used ubuntu/trusty64 vagrant box

It's the most common vagrant box with few well predefined settings.

source.list

/etc/apt/sources.list.d/ondrej-php-trusty.list
/etc/apt/sources.list.d/ondrej-php-trusty.list.save

It's in the source list, but it is still ignored. E.g. apt-cache search php7 gives always no result instead of an list.

I also destroyed the box an setup a new one.. but still the same issue.

Question

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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer


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.