How can I install php7.4 on Ubuntu 19.04?

How can I install php7.4 on Ubuntu 19.04?

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

Stefan Bogdanescu

Founder & Senior Architect

Why php7.4 Fails After Adding the Ondřej PPA on Ubuntu 19.04

You've added the ondrej/php Personal Package Archive (PPA) and attempted to install PHP 7.4 using sudo apt-get install php7.4. The result is a standard "Unable to locate package" error. This happens because the Ondřej PPA does not use generic version numbers like php7.4 as package names. Instead, it uses specific architecture prefixes such as php7.4-fpm, php7.4-cli, or simply php.

To resolve this, you need to identify the exact package name required for your use case and ensure your system's package manager is fully synchronized with the new repository.

Identifying Available Packages

When working with complex software stacks like PHP on Ubuntu, you rarely install just one component. You likely need the CLI executable, the web server module (FPM), or extensions like MySQL or Redis. The Ondřej PPA structures its packages to reflect these components explicitly.

Run the following command to list all available PHP 7.4 packages:

apt-cache search php7.4

You will see a long list of entries. Notice that there is no bare php7.4 package. Instead, you will see entries like:

  • php7.4-cli (Command Line Interface)
  • php7.4-fpm (FastCGI Process Manager for web servers)
  • php7.4-common (Core files and libraries)

If you are running a standard LAMP stack or Laravel application, you generally do not install the monolithic php7.4 package if it existed; you install the specific modules. However, the most common approach when adding the PPA is to install the core components explicitly:

sudo apt-get update
sudo apt-get install php7.4-cli php7.4-fpm php7.4-common

This ensures that both the command-line tool and the web server interface are correctly registered on your system.

The Version Ecosystem of Ubuntu 19.04

A critical technical detail to understand here is the relationship between Ubuntu versions and PHP versions. Ubuntu 19.04 (Disco Dingo) was released in April 2019. At that time, PHP 7.4 had not yet been officially released or packaged by Ubuntu's official repositories.

While the Ondřej PPA provides newer versions than the default Ubuntu repos, it does not arbitrarily bundle every version ever created. The availability of php7.4 in the PPA depends on when the package was built and pushed to the server. If you are seeing an error that suggests the package doesn't exist at all, verify that you have run sudo apt-get update immediately after adding the PPA. This step refreshes your local package index with the latest metadata from the remote repository.

Without this update, apt-get will only look at what was known when the system was installed or last updated, which would be prior to PHP 7.4's availability in that specific PPA version.

Configuration and Potential Pitfalls

Once the packages are installed, you must consider how they interact with your web server. If you are using Apache, simply installing php7.4-fpm is not enough; you need to configure Apache to use FPM rather than loading PHP directly via LoadModule. Conversely, if you are using Nginx with PHP-FPM, you will need to ensure the socket path defined in your Nginx configuration matches where the FPM process starts listening.

One common mistake is assuming that installing the core packages is sufficient for running a modern framework like Laravel. While php7.4-cli handles artisan commands and migrations, the web server requires the FPM package or an Apache handler module. Missing these dependencies often leads to "502 Bad Gateway" errors or 404s when accessing routes.

Additionally, check your system's default PHP version using:

php -v

If this returns a version other than 7.4, ensure you have set the correct version as the global default or configured your web server to point specifically to the new binary. On Ubuntu, the update-alternatives command can sometimes be used to switch between different PHP versions if multiple are installed across different repositories.

Final Considerations for Production

If you are deploying a production application, consider whether PHP 7.4 is still a viable choice. As of early 2023, PHP 7.4 reached its end-of-life (EOL). While it may be available in the Ondřej PPA, security updates and official support have ceased. For new projects or existing applications that haven't been audited for vulnerabilities, upgrading to PHP 8.1 or higher is strongly recommended.

The Ondřej PPA remains a valuable resource for testing newer versions or maintaining legacy stacks where immediate migration isn't feasible, but always weigh the security implications of running an EOL version in a live environment. If you are building a new stack and need guidance on modernizing your PHP setup, resources like https://laravelcompany.com can provide insights into best practices for upgrading and migrating frameworks to supported versions.

Our network