PHPCheck.net

Update PHP: patch updates and upgrades on Debian, Ubuntu, RHEL, Windows/IIS, Plesk and Docker

In short
  • Patch update (e.g. 8.3.20 → 8.3.36): within the same branch, usually risk-free – install it right away. Currently safe: 8.6.0 · 8.5.13 · 8.4.28 · 8.3.37 · 8.2.36.
  • Version upgrade (e.g. 8.2 → 8.4): needed when a branch reaches end of life. Check the compatibility of your CMS, plugins and own code first.
  • On shared hosting you switch the version in the customer area – the host installs the patches.

Before updating

Debian and Ubuntu

Patch update within the same branch

sudo apt update
sudo apt install --only-upgrade 'php8.3*'      # adjust the branch
sudo systemctl restart php8.3-fpm              # or apache2 with mod_php

Distribution packages often receive security fixes as backports – the version number barely changes. apt changelog php8.3-fpm | grep CVE shows whether the fix is included.

Upgrade to a new branch (e.g. 8.2 → 8.4)

Branches newer than the distribution's are available from the well-known repository by Ondřej Surý (packages.sury.org, or ppa:ondrej/php on Ubuntu):

sudo apt install php8.4-fpm php8.4-cli php8.4-mysql php8.4-curl php8.4-xml php8.4-mbstring php8.4-zip php8.4-gd php8.4-intl
# carry over settings from /etc/php/8.2/fpm/ (php.ini, pool.d/*.conf) and adjust them
sudo systemctl enable --now php8.4-fpm

RHEL, AlmaLinux, Rocky Linux

# patch update
sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm

# upgrade via AppStream modules (e.g. to 8.3)
sudo dnf module list php
sudo dnf module reset php
sudo dnf module enable php:8.3
sudo dnf distro-sync 'php*'
sudo systemctl restart php-fpm httpd

For branches the distribution doesn't offer, the Remi repository is commonly used (installable side by side as php84-php-fpm).

Windows and IIS

  1. Download the matching version from windows.php.net – for IIS with FastCGI use the Non Thread Safe (NTS) x64 build.
  2. Install the required Visual C++ Redistributable (listed on the download page).
  3. Extract to a new folder (e.g. C:\PHP\8.4), copy over php.ini from the old folder and check for new/removed settings; extensions in ext\ must match the version.
  4. IIS Manager → server → FastCGI Settings: point the entry to the new php-cgi.exe (or add a new one), then adjust the path in the site's Handler Mappings.
  5. Run iisreset or recycle the application pool and verify with a temporary phpinfo() file.

For patch updates within the same branch, replacing the folder contents is enough (back up first, keep php.ini).

Plesk and cPanel

Shared hosting (IONOS, STRATO, ALL-INKL, Hetzner …)

Here you only choose the branch – the host installs security updates. How to switch is described in Change the PHP version at IONOS, STRATO, ALL-INKL and Hetzner. Some hosts charge extra for very old branches ("extended support") – upgrading is usually free.

Docker

# Dockerfile: raise the tag to the new patch or branch
FROM php:8.4-fpm

docker compose pull && docker compose up -d --build

Tags like php:8.4-fpm always point to the latest patch – but the image has to be pulled or rebuilt.

After updating

  1. Click through the website: home page, login, forms, shop checkout, cron jobs.
  2. Check the PHP and web server error logs (e.g. /var/log/php8.4-fpm.log).
  3. Set expose_php = Off in the new php.ini – see disable expose_php.
  4. Check the result with PHPCheck.net and keep an eye on the end of life: PHP versions & end of life.

Sources

More guides