Yuki Terasaka

Installing Multiple PHP Versions on Ubuntu 26.04

A guide to installing multiple PHP versions on Ubuntu 26.04.

When you needed multiple PHP versions on Ubuntu, the usual approach was to add ppa:ondrej/php. However, when I tried adding that PPA on Ubuntu 26.04 using the same approach that worked through 24.04, I received the following error:

Error: The repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu resolute Release' does not have a Release file.

After looking into it, I found that this PPA is no longer available for Ubuntu 26.04 (Resolute). PHP package maintainer Ondrej Sury has consolidated the packages into packages.sury.org instead. The background is documented in the following issue:

The issue explains that packages for new Ubuntu LTS releases from 26.04 onward will be provided through packages.sury.org, a shared repository for Debian and Ubuntu, rather than through the Launchpad PPA.

Most articles about installing PHP on Ubuntu 26.04 focus on installing PHP 8.5 from the official APT repositories. As far as I could find, the issue above was the only source that covered installing multiple PHP versions using packages.sury.org. This article documents the procedure.

Installation Steps

The issue reports the following steps.

1. Remove the old PPA, if applicable

If you previously added ppa:ondrej/php, remove it first to prevent 404 errors when running apt update. Skip this step when installing PHP on a new system.

sudo add-apt-repository --remove ppa:ondrej/php

2. Add the new repository

Install the GPG keyring for packages.sury.org, then add the new repository under sources.list.d. If PHP is already installed, run apt-get upgrade at the end to upgrade to packages from the new repository.

sudo apt-get update
sudo apt-get -y install lsb-release ca-certificates curl

# Install the GPG keyring from the .deb package.
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb

# lsb_release -sc automatically detects "resolute" on Ubuntu 26.04.
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

sudo apt-get update
sudo apt-get upgrade

3. Install multiple PHP versions

Once the repository has been switched, usage is the same as it was with ppa:ondrej/php.

sudo apt install php8.3 php8.3-fpm php8.3-cli
sudo apt install php8.4 php8.4-fpm php8.4-cli

# Switch the active version.
sudo update-alternatives --config php
All articles