Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

apt cannot find php8.0 (or another older PHP) on Ubuntu

ErrorCouldn't find any package by glob 'php8.0'

Short answer

Ubuntu 24.04 ships php8.3 in its own repositories, so a package named php8.0 does not exist there. Install the version your release provides, or add the PPA that carries other versions. PHP 8.0 and 8.1 are end of life, so the better fix is to move the app to a supported version.

  • Applies to Ubuntu 24.04, PHP 8.3, PHP 8.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask apt which php packages your release really offers. If only one version shows up, that is the version in the standard repositories.

    lsb_release -cs
    apt-cache policy php8.3 php8.0
    apt-cache search --names-only '^php[0-9]\.[0-9]$'
  2. 2Match what you see, then jump to its fix

    1. 1apt-cache policy php8.0 shows no candidate while php8.3 has oneThe release's own repositories carry only one PHP versionFix
    2. 2apt-cache policy shows no source for the version you wantYou need another PHP branch and have not added the PPAFix
    3. 3The app or its guide was written for PHP 8.0 or 8.1The version you ask for has reached end of lifeFix

What does the error look like?

  • Couldn't find any package by glob 'php8.0'

Cause 1 of 3

The release's own repositories carry only one PHP version

1Check

The Ubuntu package search for the noble release (24.04) lists php8.3 packages. A php8.0 package is not offered there, so a search for it finds nothing.

apt-cache policy php8.3 php8.0

2Fix

Install the PHP version the release provides, with the extensions your app needs, and update the app to run on it.

sudo apt update
sudo apt install php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml php8.3-mbstring

3Verify

Check the installed version.

php -v

Confirmed by packages.ubuntu.com

Did this fix it?

Cause 2 of 3

You need another PHP branch and have not added the PPA

1Check

The ondrej/php PPA on Launchpad builds other PHP versions for Ubuntu. Its page lists Noble (24.04) and Jammy (22.04) as series, calls the PPA unsupported and untrusted, and says it is being merged into packages.sury.org. Check whether it is already on the machine.

grep -rl "ondrej" /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null

2Fix

Add the PPA, update the package index, and install the version you need, with its extensions. Run apt update again after adding the PPA.

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.4-cli php8.4-fpm

3Verify

Confirm apt now sees the version.

apt-cache policy php8.4

Confirmed by launchpad.net

Did this fix it?

Cause 3 of 3

The version you ask for has reached end of life

1Check

The PHP project lists 8.2, 8.3, 8.4 and 8.5 as supported branches. PHP 8.0 and 8.1 are end of life and get no security fixes.

php -v

2Fix

Upgrade the application to a supported branch, 8.3 or 8.4 on Ubuntu 24.04, then fix deprecations it reports instead of pinning an old version.

sudo apt install php8.4-cli

3Verify

Run the test suite or a smoke test on the new version.

php -v && composer install --no-interaction

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • Pick the PHP version from the release's repositories, or from the PPA, before you write deployment scripts.
  • Pin versions in the deployment script and check apt-cache policy in CI.
  • Track the PHP support dates and plan upgrades before a branch ends security support.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

nginx gives up waiting for the app and returns 504

upstream timed out (110: Connection timed out) while reading response header from upstream

nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.

5 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.