How to update PHP on Ubuntu for a security release
by Stephen Meehan in Server Logs, Maintenance Services
Updating PHP on Ubuntu took about ten minutes per server when I patched a client's production and staging servers on 20 November 2026. PHP had published a security release the day before, and both servers were running PHP 8.5.12.
Below are the commands I ran, in order, and the output that tells you each one worked. They suit any Ubuntu server that gets PHP from Ondřej Surý's packages, which is where Ploi, the server management tool I use, installs it from.
Why update PHP on Ubuntu to 8.5.13?
PHP 8.5.13 is a security release, published on 19 November 2026. PHP's announcement says "All PHP 8.5 users are encouraged to upgrade to this version." PHP 8.4.28 and 8.3.37 came out the same day with the same fixes for those versions.
Several of the fixes are in PHP FastCGI Process Manager (PHP-FPM), the part of PHP that handles each visit to a website. Every site on these servers runs through it. I covered the vulnerabilities, and which sites are exposed to them, in my post on the November 2026 PHP security release. The full list is in PHP's changelog for 8.5.13.
8.5.13 is a patch release, so it stays on PHP 8.5. It fixes bugs and security vulnerabilities without changing how a site's code behaves. That's why it can go on straight away, without the testing a move to a new version such as PHP 8.6 needs.
Staying on the latest patch release is the simplest protection a server has against known security vulnerabilities.
Statamic Watchtower lists every security release for the software a Statamic site runs, in one place. It checks for new releases every hour, and it's free for anyone to use.
The commands, and what each one should show
Take a snapshot of the server before you start, it's the quickest way back if an update goes wrong.
Check which PHP version is running
php -vThe first line shows the version. On both servers it was PHP 8.5.12 (cli).
See which PHP packages have an update
sudo apt update
apt list --upgradable 2>/dev/null | grep -i phpapt update refreshes the list of packages available to apt, Ubuntu's package manager. It ends with a count such as 46 packages can be upgraded. The second command lists only the PHP packages, each ending in [upgradable from: 8.5.12-1...]. If it prints nothing, PHP is already up to date.
Both servers also had PHP 8.3 and 8.4 installed as command-line tools, so those showed up in the list too.
Upgrade only the PHP packages
sudo apt install --only-upgrade 'php8.3*' 'php8.4*' 'php8.5*'The wildcards match every PHP 8.3, 8.4 and 8.5 package. --only-upgrade updates the ones already installed and doesn't add any new ones. The other updates waiting on the server stay as they are, so a kernel update can't slip in and need a restart.
Expect a long run of Note, selecting and Skipping ..., it is not installed lines first. That's the wildcard matching packages the server doesn't have, and it's normal. The line to check is the summary:
28 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.At the end, Ubuntu restarts any service still using the old files. Here it printed systemctl restart supervisor.service. Supervisor keeps the site's queue workers running, the background processes that handle jobs such as sending emails.
Restart PHP-FPM
sudo systemctl restart php8.5-fpm
systemctl is-active php8.5-fpm supervisorRestarting PHP-FPM makes every part of it load the new version. A visitor loading a page in that second may see an error, so pick a quiet time. systemctl is-active should print active twice, once for PHP-FPM and once for Supervisor.
Confirm the new PHP version
php -vThe first line should now read PHP 8.5.13 (cli) (built: Nov 19 2026 ...).
Check the queue workers
sudo supervisorctl statusEach worker should show RUNNING with an uptime of a minute or two. The short uptime confirms they restarted on the new PHP.
Restart the queue workers from the site
cd ~/example.com
php artisan queue:restartRun this from the site folder as the user the site runs as, which is ploi on a Ploi server. Statamic is built on Laravel, so the Laravel command works. It prints INFO Broadcasting queue restart signal. Supervisor had already restarted the workers, so this is a belt-and-braces step that does no harm.
Finally, load the website and its Control Panel (CP) to check both work as before.
What I left for another day
Each server offered more than the PHP update. I left three things alone on purpose.
The other updates waiting on each server. Those go on separately, after another snapshot, in case one needs a restart.
sudo apt autoremove, which offered to remove two libraries nothing uses any more. It's harmless either way.The login message saying Ubuntu 26.04 is available. Moving a server to a new version of Ubuntu is a bigger job that needs its own plan, and it starts on staging.
How often does PHP need updating?
PHP publishes a new patch release roughly every four weeks, and a security release can need installing within days. The commands stay the same each time, and only the version number changes.
Keeping PHP patched is part of every website maintenance plan I offer. Sites on a plan get releases like this one installed and checked without their owners having to ask.