E: Couldn't find any package by glob 'php-7.4'

E: Couldn't find any package by glob 'php-7.4'

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Why apt Refuses to Install PHP 7.4 on Ubuntu 22.04

If you are attempting to install PHP 7.4 on Ubuntu 22.04 and encounter the error E: Couldn't find any package by glob 'php-7.4', the root cause is not a broken package manager or a missing repository configuration. It is a fundamental mismatch between the default software repositories provided by your operating system and the specific version of PHP you are requesting.

Ubuntu 22.04 LTS ships with PHP 8.1 as its default version in the main universe repository. The official Debian-based archives have moved past PHP 7.4, which reached end-of-life (EOL) in November 2022. Consequently, the package name php-7.4, php7.4-fpm, or similar variants simply do not exist in the standard apt sources configured for this specific OS version.

Attempting to force an installation using commands like sudo apt install php-7.4 will inevitably fail with a 404 error or the "package by glob" message you are seeing. While many online tutorials suggest adding third-party repositories (such as Ondrej's PHP repository) to solve this, simply copying and pasting those instructions without understanding the underlying implications can lead to security vulnerabilities or dependency conflicts.

Understanding the Repository Architecture

The solution involves either accepting the default modern version of PHP or explicitly configuring a third-party repository that hosts older versions. However, there is a critical trade-off here regarding system stability.

The Ubuntu 22.04 repositories are curated for long-term support (LTS), ensuring that packages installed via apt have been tested against the specific kernel and library versions shipped with the OS. PHP 7.4 was released in 2018. The libraries it depends on (libxml, zlib, etc.) have evolved significantly since then. Installing a package built for an older ecosystem into a newer base can sometimes lead to subtle runtime issues, even if the installation command succeeds.

Option 1: Using the Official Ondrej Repository

The most common workaround is adding Ondrej's PHP repository, which maintains backports of popular versions including 7.4. This is generally safe for development environments but requires precise configuration to avoid breaking the system apt cache.

First, you must ensure your system packages are updated before attempting any changes:

sudo apt update && sudo apt upgrade -y

Next, add the GPG key and repository list specifically for Ubuntu 22.04 (Jammy):

wget https://packages.sury.org/php/apt.gpg
sudo gpg --dearmor -o /usr/share/keyrings/php-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://packages.sury.org/php/ jammy main" | sudo tee /etc/apt/sources.list.d/php.list

Once the list is added, update your package index again:

sudo apt update

Now you can search for the specific packages. Note that the exact package name might differ slightly depending on whether you need CLI, FPM, or CLI with common extensions. You might find packages named php7.4-cli, php7.4-fpm, or just php7.4:

sudo apt search php7.4

If the installation succeeds, you can switch the active PHP version using a tool like alter-php or by modifying your web server configuration (e.g., Apache PHPVersionDirective or Nginx fastcgi_param) to point to /usr/bin/php7.4.

Option 2: Staying with Default PHP Versions

If you are building a production application, particularly one utilizing modern frameworks like Laravel, it is often advisable to stay with the version provided in the official Ubuntu repositories (PHP 8.1 or later for Ubuntu 22.04).

Many modern PHP extensions and framework versions have dropped support for PHP 7.4 entirely. If you install PHP 7.4 via a third-party repository, you may find yourself unable to use the latest composer packages or encountering security patches that are no longer available for that specific version stream.

If your project specifically requires PHP 7.4 logic, consider running it in an isolated container environment using Docker. This allows you to run ubuntu:20.04 with PHP 7.4 inside the container while maintaining the stability of a newer host OS. This approach isolates the legacy dependency without risking the integrity of your main server.

Conclusion on Version Management

The error message is a protective mechanism from the package manager, alerting you that the requested software does not exist in the trusted sources for your current system version. While adding repositories like Ondrej's allows you to install older versions, it introduces complexity regarding dependency resolution and security updates. For new projects, aligning with the default PHP 8.x versions offered by Ubuntu 22.04 is the most robust path forward.

Our network