Update PHP: patch updates and upgrades on Debian, Ubuntu, RHEL, Windows/IIS, Plesk and Docker
- 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
- Back up files, database and PHP configuration (
php.ini, FPM pools). - Which version is running now? See Check the PHP version and patch level.
- When upgrading to a new branch: update your CMS, themes and plugins first and check their minimum/maximum versions. Scan your own code with
PHPCompatibility(PHP_CodeSniffer) or Rector for deprecated functions. Ideally test on a staging copy first. - Save the list of required extensions:
php -m > php-modules.txt
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
- Apache with PHP-FPM:
sudo a2disconf php8.2-fpm && sudo a2enconf php8.4-fpm && sudo systemctl reload apache2 - nginx: set
fastcgi_pass unix:/run/php/php8.4-fpm.sock;in the site configuration, thensudo nginx -t && sudo systemctl reload nginx - Command line:
sudo update-alternatives --set php /usr/bin/php8.4 - Once everything works, remove the old branch:
sudo apt purge 'php8.2*'
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
- Download the matching version from windows.php.net – for IIS with FastCGI use the Non Thread Safe (NTS) x64 build.
- Install the required Visual C++ Redistributable (listed on the download page).
- Extract to a new folder (e.g.
C:\PHP\8.4), copy overphp.inifrom the old folder and check for new/removed settings; extensions inext\must match the version. - 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. - Run
iisresetor recycle the application pool and verify with a temporaryphpinfo()file.
For patch updates within the same branch, replacing the folder contents is enough (back up first, keep php.ini).
Plesk and cPanel
- Plesk: patch updates arrive via Tools & Settings → Updates. Install new branches under Add/Remove Components → PHP interpreter, then switch per domain under PHP.
- cPanel/WHM: EasyApache 4 → add the new
ea-phpversion; switch per domain in the MultiPHP Manager. Patch updates come with the regular system updates (yum/dnf update).
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
- Click through the website: home page, login, forms, shop checkout, cron jobs.
- Check the PHP and web server error logs (e.g.
/var/log/php8.4-fpm.log). - Set
expose_php = Offin the newphp.ini– see disable expose_php. - Check the result with PHPCheck.net and keep an eye on the end of life: PHP versions & end of life.
Sources
- php.net: Supported Versions
- php.net: Migrating to PHP 8.4
- deb.sury.org (Ondřej Surý)
- PHP for Windows