apt cannot find php8.0 (or another older PHP) on Ubuntu
Couldn'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.
Fix it fast
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]$'2Match what you see, then jump to its fix
- 1
apt-cache policy php8.0 shows no candidate while php8.3 has oneThe release's own repositories carry only one PHP versionFix - 2
apt-cache policy shows no source for the version you wantYou need another PHP branch and have not added the PPAFix - 3
The app or its guide was written for PHP 8.0 or 8.1The version you ask for has reached end of lifeFix
- 1
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.02Fix
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-mbstring3Verify
Check the installed version.
php -vConfirmed by packages.ubuntu.com
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/null2Fix
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-fpm3Verify
Confirm apt now sees the version.
apt-cache policy php8.4Confirmed by launchpad.net
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 -v2Fix
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-cli3Verify
Run the test suite or a smoke test on the new version.
php -v && composer install --no-interactionConfirmed by php.net
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
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Composer reports a different PHP version than php -v on Ubuntu
You are running 8.1.2.
Composer takes its PHP version from the interpreter that runs it, unless config.platform fakes one.
3 causes, each with a fixServers
docker-php-ext-install mbstring fails: oniguruma not found
The docker-php-ext-install step exits with a non-zero code
mbstring needs the Oniguruma library to build its regex functions, and the PHP build finds it through pkg-config.
3 causes, each with a fixServers
Laravel returns 500 Internal Server Error on Apache
/var/www/html/.htaccess: RewriteCond: bad flag delimiters
Apache and Laravel report different 500s.
5 causes, each with a fixServers
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 fixServers
nginx and PHP-FPM show File not found or Primary script unknown
File not found.
PHP-FPM received a script path it could not turn into a file.
4 causes, each with a fix