Ubuntu 26.10, 26.04, 24.04, 22.04 and older LTS releases

How to install or update PHP on Ubuntu

Whether you are installing PHP on Ubuntu or patching it, apt gives you Ubuntu's own build, and its version number will not match php.net's. Ubuntu fixed PHP2Shell on 21 October 2026 in USN-8948-1 by adding a new package revision. Upgrade, restart PHP-FPM or Apache, then check your exact version against the notice.

Last reviewed against Ubuntu's security notices, the Ubuntu archive, packages.sury.org and php.net.

Ubuntu packages checked 27 October 2026

The fixed PHP build for each Ubuntu release

Ubuntu published two notices on 21 October 2026 and gives both CVEs its Critical priority. Each row covers CVE-2026-109618 and CVE-2026-109619 together: your PHP packages are patched when they are at the version shown or above it.

Release Ubuntu's PHP Fixed in Notice How it is delivered
Ubuntu 26.10 php8.5 8.5.9-0ubuntu2.1 USN-8948-1 Standard updates
Ubuntu 26.04 LTS php8.5 8.5.4-0ubuntu1.5 USN-8948-1 Standard updates
Ubuntu 24.04 LTS php8.3 8.3.6-0ubuntu0.24.04.13 USN-8948-1 Standard updates
Ubuntu 22.04 LTS php8.1 8.1.2-1ubuntu2.28 USN-8948-1 Standard updates
Ubuntu 20.04 LTS php7.4 7.4.3-4ubuntu2.29+esm5 USN-8948-2 Ubuntu Pro
Ubuntu 18.04 LTS php7.2 7.2.24-0ubuntu0.18.04.17+esm14 USN-8948-2 Ubuntu Pro
Ubuntu 16.04 LTS php7.0 7.0.33-0ubuntu0.16.04.16+esm22 USN-8948-2 Ubuntu Pro, Legacy Support add-on
Ubuntu 14.04 LTS php5 5.5.9+dfsg-1ubuntu4.29+esm18 USN-8948-2 Ubuntu Pro, Legacy Support add-on

Which packages the notice covers

USN-8948-1 lists four binary packages per release: the command line build (php8.3-cli on 24.04), PHP-FPM (php8.3-fpm), the Apache module (libapache2-mod-php8.3) and CGI (php8.3-cgi). They all share one version, so whichever of them you run should show the same fixed string.

Why the number looks old

Ubuntu keeps each release on the PHP version it launched with and patches that version, so the fixed 24.04 build still begins 8.3.6. Ubuntu's own security documentation warns that tools judging packages by that leading number raise false alarms. The part after the first hyphen is what changes with each fix. More on this on the Linux overview.

Primary sources: USN-8948-1, USN-8948-2, Ubuntu's CVE-2026-109618 page and Ubuntu's CVE-2026-109619 page. For the PHP project's own numbers, see PHP2Shell explained.

Step by step

Update PHP on Ubuntu in five steps

The examples use Ubuntu 24.04, where the branch is 8.3. On 26.04 replace 8.3 with 8.5, and on 22.04 with 8.1.

  1. Find out what is installed, and from where

    # Every PHP package on the server, with its exact version
    dpkg-query -W 'php*' 'libapache2-mod-php*'
    
    # Where the installed and candidate builds come from
    apt-cache policy php8.3-fpm

    The first command prints each PHP package with its full version. The second shows the installed and available versions and which archive offers each. A version string such as 8.3.36-1+ubuntu24.04.1+deb.sury.org+1 or 8.3.36-1+0~20261021.88+ubuntu24.04~1.gbp250f7c belongs to Ondřej Surý's repositories, not Ubuntu: skip to that section.

  2. Install the updates

    sudo apt update
    sudo apt upgrade

    apt update refreshes the package lists, and apt upgrade brings every installed package to its newest version without removing any. If a change window only allows PHP to move, upgrade the PHP packages alone:

    # Upgrade just the PHP packages that are already installed
    sudo apt-get install --only-upgrade php8.3-cli php8.3-fpm libapache2-mod-php8.3

    With --only-upgrade, any package in that list that is not installed is skipped rather than added.

  3. Prove the fix is in the package

    # The newest entry should name both CVE IDs
    apt-get changelog php8.3-fpm | head -n 12
    
    # Or let dpkg compare your version with the one in the notice
    dpkg --compare-versions YOUR-VERSION ge 8.3.6-0ubuntu0.24.04.13 && echo fixed

    On 27 October 2026 the newest changelog entry on a patched 24.04 server was 8.3.6-0ubuntu0.24.04.13 for noble-security. It names both CVE IDs and adds the patch CVE-2026-109618_109619.patch. The dpkg --compare-versions line applies Debian's version ordering, which is safer than comparing the strings by eye. The Ubuntu Pro client can run the same check for you; with --dry-run it reports without installing anything:

    pro fix CVE-2026-109618 --dry-run
  4. Restart PHP

    # One PHP-FPM service per installed branch
    systemctl list-units 'php*-fpm*'
    sudo systemctl restart php8.3-fpm
    
    # Only if PHP runs inside Apache as mod_php
    sudo systemctl restart apache2

    The PHP-FPM service is named after its branch, so a server with PHP 8.1 and 8.3 side by side has two to restart. Running processes keep the old code in memory until they are replaced, which is why this step matters. There is more on worker restarts in the PHP-FPM guide, and on mod_php in PHP on Apache.

  5. Check the running service

    systemctl status php8.3-fpm
    php-fpm8.3 -v

    The Active: line of systemctl status gives the time the service last started, which should be after the upgrade. php-fpm8.3 -v prints the FPM binary's version. Then follow the checks below to see what the website itself is running.

Know your source

Four places your Ubuntu PHP can come from

The update command barely changes between them. What changes is which version counts as fixed, and whether Ubuntu's automatic security updates will install it for you.

3D stack of reference books with a padlock, for Ubuntu's own archive

Ubuntu's own archive

Installed with a plain apt install php or php-fpm. Fixed versions keep the release's original PHP number and gain a new Ubuntu revision, so compare against the table above, not against php.net.

The step-by-step update
3D badge with a green tick, for Ubuntu Pro on older releases

Ubuntu Pro (20.04 and older)

Ubuntu 20.04 and 18.04 are past standard support, so their fixed PHP builds come through Ubuntu Pro's Expanded Security Maintenance, and the machine has to be attached to it.

Patching an older LTS release
3D group of users around a secured server, for a community PPA

The Ondřej Surý PPA

Version strings ending in +deb.sury.org+1 come from here. It packages the PHP project's own releases for Ubuntu 22.04 and 24.04, so php.net's fixed numbers apply directly.

Updating from the PPA
3D server and monitor downloading updates, for packages.sury.org

packages.sury.org

The same maintainer's newer repository, which the PPA is being merged into. It is already the route for Ubuntu 26.04 and carries builds for 22.04 and 24.04 too.

Moving to packages.sury.org

Ubuntu 20.04, 18.04, 16.04 and 14.04

Patching PHP on an older LTS release

USN-8948-2 fixed PHP 7.4 on 20.04 and PHP 7.2 on 18.04, but the packages are only reachable through Ubuntu Pro. For 16.04 (PHP 7.0) and 14.04 (PHP 5.5) the subscription also needs the Legacy Support add-on. A server that is not attached sees no update at all.

sudo pro attach YOUR-TOKEN
pro status
sudo pro enable esm-apps     # only if pro status shows it disabled
sudo apt update && sudo apt upgrade

The token comes from the Ubuntu Pro dashboard. Pro splits its coverage in two: ESM-Infra covers packages in Ubuntu's main component, and ESM-Apps covers universe. On 20.04 the PHP command line build and Apache module sit in main, while php7.4-fpm sits in universe, so a PHP-FPM server needs ESM-Apps switched on as well. pro status shows which services are enabled.

A patched PHP 7.4 is still PHP 7.4

Ubuntu Pro closes these two flaws in Ubuntu's own build. The PHP project stopped supporting PHP 7.4 in November 2022, so treat the Pro fix as time to plan a release upgrade rather than a reason to stay. The PHP end of life page sets out the dates and options.

Third-party PHP on Ubuntu

The Ondřej Surý PPA, and its move to packages.sury.org

Servers that need a PHP branch Ubuntu does not ship usually take it from Ondřej Surý's repositories. These package the PHP project's releases, so here the php.net numbers do apply: 8.2.35, 8.3.36, 8.4.27 or 8.5.12 and later are fixed.

Updating from the PPA (Ubuntu 22.04 and 24.04)

If the PPA is already configured, the normal upgrade from step 2 installs its fixed builds. On a new server, it is added like this:

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade

On 27 October 2026 the PPA's 24.04 index held, for example, php8.3-fpm 8.3.36-1+ubuntu24.04.1+deb.sury.org+1. Its own Launchpad page calls them unsupported packages from an untrusted PPA, so weigh that before adding it to a production server.

packages.sury.org (Ubuntu 26.04, and the future route for older releases)

The PPA is being folded into packages.sury.org. For Ubuntu 26.04 the new repository is already the canonical source, and the PPA does not publish 26.04 builds. The repository's README gives a setup script; its steps are:

sudo apt-get install lsb-release ca-certificates curl
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update

The repository line takes the release codename from lsb_release -sc, and the repository publishes suites for Ubuntu 22.04, 24.04 and 26.04. Its builds were dated 21 October 2026 and carry the fixed upstream versions. It also rebuilt PHP 7.4, 8.0 and 8.1 that day; the 8.1 package's changelog lists both CVE IDs as a backported fix.

Automatic updates skip it. Adding a repository does not make unattended-upgrades use it. Ubuntu's documentation says to add the repository's Origin, found in its Release or InRelease file, to Allowed-Origins; for a PPA the Origin takes the form LP-PPA-user-name.

One source per branch. Mixing Ubuntu's php8.3 packages with the PPA's php8.3 packages makes it hard to say which build is live. Run dpkg-query -W 'php8.3*' and check that every package carries the same kind of version string.

New servers

Installing PHP on Ubuntu

A fresh install from Ubuntu's archive gets the fixed build as long as the package lists are current, so run sudo apt update first.

# PHP-FPM, the setup php.net recommends
sudo apt install php-fpm

# Apache with mod_php, as in Ubuntu's server guide
sudo apt install php libapache2-mod-php

The unversioned names resolve to the release's own branch: PHP 8.5 on 26.04, PHP 8.3 on 24.04 and PHP 8.1 on 22.04. Choose the first line where you can: php.net's Apache page steers new installations away from mod_php towards PHP-FPM, and mod_php is the setup in which PHP2Shell code execution was confirmed.

Keeping it patched

What Ubuntu does on its own

Out of the box, Ubuntu runs unattended-upgrades every day, and it installs security fixes from Ubuntu's archive without being asked. From 24.04, needrestart then restarts the services that were using the replaced files.

# What the next automatic run would install, without installing it
sudo unattended-upgrade -v --dry-run

# What earlier runs did
ls /var/log/unattended-upgrades/

The settings live in /etc/apt/apt.conf.d/50unattended-upgrades and 20auto-upgrades. If the logs show the PHP2Shell packages went in days ago, what is left is to confirm the restart happened and the site runs the new build.

Confirm it worked

Four checks before you call an Ubuntu server fixed

  1. 1. Every PHP package shows a fixed version. dpkg-query -W 'php*' should list only versions at or above the table row for your release, for every branch installed.
  2. 2. Each PHP service started after the upgrade. The Active: time from systemctl status should be later than the upgrade, whether you ran it or unattended-upgrades did.
  3. 3. The website reports the build you patched. The command line and the web server can run different PHP builds, so read the version through the site itself. How to check your PHP version.
  4. 4. Nothing else on the network still runs the old build. Staging servers, other cluster members and container images need the same update. Images built on Ubuntu keep their PHP until they are rebuilt: updating PHP in Docker.

An Ubuntu server that faced the internet while unpatched deserves a look for intruders as well, since both CVEs have been on CISA's Known Exploited Vulnerabilities catalogue since 26 October 2026: signs of a compromised PHP site. If you cannot patch today, work out whether to take the site offline.

Troubleshooting

When the Ubuntu update does not go to plan

apt says PHP is already the newest version, but it is below the table

Run sudo apt update before upgrading, then look at apt-cache policy php8.3-fpm. If no security or updates archive appears in its list, the server's APT sources are incomplete or point at a mirror that has not caught up.

Some PHP packages were left out of the upgrade

apt upgrade never removes a package, so an upgrade that needs a removal is not applied. Check for holds with apt-mark showhold. apt full-upgrade is allowed to remove packages, so read its list before you agree to it.

PHP-FPM will not start again

Read the service log and test the configuration. A pool file edited by hand, for example to add the interim PHP2Shell settings, is the usual suspect.

apt-mark showhold
journalctl -u php8.3-fpm -e
sudo php-fpm8.3 -t

Ubuntu 20.04 or 18.04 shows no PHP update

The machine is not attached to Ubuntu Pro, or ESM-Apps is off and the server runs PHP-FPM. pro status tells you which. pro security-status lists the security updates waiting for installed packages, including those from Expanded Security Maintenance.

A vulnerability report still flags the patched server

If the report quotes PHP 8.3.6 or 8.1.2, it is reading the upstream number and cannot see Ubuntu's fix. Keep the dpkg-query output and the changelog entry from step 3 with the report as your evidence.

The site still shows an old PHP version after a PPA update

With several branches installed, the web server may be pointed at a different PHP-FPM service from the one you restarted. systemctl list-units 'php*-fpm*' lists them all; restart each, or check the site's handler configuration.

Running Debian rather than Ubuntu? The security archive works differently there: updating PHP on Debian. For RHEL, AlmaLinux or Rocky Linux, see the dnf guide. Every other environment is on the main update guide.

Quick answers

PHP on Ubuntu: common questions

Which PHP version does Ubuntu 24.04 install?

PHP 8.3. On Ubuntu 24.04 the php, php-fpm and libapache2-mod-php packages are small dependency packages that pull in the php8.3 builds. Ubuntu 26.04 LTS installs PHP 8.5 the same way, and Ubuntu 22.04 installs PHP 8.1. Any other branch on those releases has to come from a third-party repository.

Is PHP 8.3.6 on Ubuntu 24.04 safe from PHP2Shell?

Only if the full package version is 8.3.6-0ubuntu0.24.04.13 or later. Every Ubuntu 24.04 PHP build starts with 8.3.6, so the upstream number on its own tells you nothing. Run dpkg-query -W 'php8.3*' and compare the whole string with USN-8948-1.

Do I need Ubuntu Pro to fix PHP on Ubuntu 20.04?

For Ubuntu's own PHP package, yes. USN-8948-2 publishes the 20.04 and 18.04 fixes through Ubuntu Pro only, and 16.04 and 14.04 also need the Legacy Support add-on. The Ondřej Surý repositories no longer publish 20.04 builds, so the only other route is upgrading the server to a supported Ubuntu release.

PHP end of life dates

Is the Ondřej Surý PPA still the way to get newer PHP on Ubuntu?

For Ubuntu 22.04 and 24.04 it still works, and on 27 October 2026 it carried the fixed 8.2.35, 8.3.36, 8.4.27 and 8.5.12 builds. Its Launchpad page says it is being merged into packages.sury.org, which is already the canonical source for Ubuntu 26.04, with a migration path for older releases promised.

Does apt upgrade restart PHP-FPM for me?

Often, but do not rely on it. From Ubuntu 24.04, needrestart restarts services affected by an upgrade by default, although it keeps a list of services it never restarts and the setting can be changed. Check the start time with systemctl status php8.3-fpm after every PHP update, and restart Apache yourself if it runs mod_php.

3D rocket illustration above the call to find every exposed PHP server

Know your exposure

Find every PHP server you run

Patching the server you know about is the easy part. A vulnerability scan finds the forgotten staging site, the old microsite and the appliance with PHP inside, then tells you which ones are still exposed.