Upgrade PHP in production without downtime: canary, reload and rollback
Switching PHP versions is not a deploy: it is two FPM pools, two sockets and two OPcache instances. With a canary and an ordered reload the site never notices. With a restart at eleven in the morning, it does.
Why now: the November 19 release
The PHP team shipped 8.2.36, 8.3.37, 8.4.28 and 8.5.13 on November 19. By BleepingComputer's count that is 18 flaws fixed and seven of them critical, including CVE-2026-115560 in session upload progress, CVE-2026-126714 (phpAfterShell) in the file-based session handler and CVE-2026-129289 in PHP-FPM with request bodies that are never read. Cloudflare pushed an emergency WAF release the same day.
Installing the patch takes half an hour. The half nobody documents is the other one: changing the version that actually serves your application, live, with a rollback that takes a minute. If your deploys already use symlinked releases, the file side is solved; if not, start with the Laravel 13 deployment guide and come back. This piece is only about the runtime.
Before you touch anything: inventory
Which binary serves which site
The basic mistake is assuming the php in your shell is the one answering requests. It does not have to be. Check the three layers separately:
Read also
php -v; which php
ls -l /run/php/*.sock
systemctl list-units 'php*-fpm*'
Then the real destination inside nginx: grep -rn fastcgi_pass /etc/nginx/. That socket is the truth. Everything else is a hint.
Extensions and platform
Save the old branch's module list to a file, because you will compare against it at the end:
php -m > /tmp/php-old-modules.txt
Before installing anything, let Composer act as a traffic light. composer check-platform-reqs reports which extensions the project needs and whether they are present; composer why-not php 8.5 lists the packages blocking the target branch. If an extension has no build for the new version, the change stops here, not halfway through a reload.
Install the new branch side by side
Per-version packages and services
On Debian and Ubuntu with the Sury repository, each branch is its own package and its own service. Installing 8.5 leaves 8.2 alone:
apt install php8.5-fpm php8.5-cli php8.5-mysql php8.5-mbstring php8.5-xml php8.5-curl php8.5-zip php8.5-bcmath php8.5-intl
Two services now run at once, each with its own socket. Nothing gets uninstalled yet: that is the safety net. On other distributions the package names differ but the pattern does not: one pool per branch, one socket per pool.
Validate the configuration
Before starting anything, check the new pool's syntax and compare it against the old one: user, listen, pm.max_children, slowlog. Defaults differ between packages, and a pm.max_children of 5 where there used to be 25 turns into a queue.
php-fpm8.5 -t
If the config passes, start the service. Nginx still points at the old socket, so nothing has changed for visitors yet.
systemctl start php8.5-fpm
Move traffic without cutting it
Point nginx at the new socket
A single word separates the change from the outage: the destination of fastcgi_pass.
fastcgi_pass unix:/run/php/php8.5-fpm.sock;
Then nginx -t and systemctl reload nginx. An nginx reload does not take the service down: the master re-reads the config and old workers finish what they were doing. A restart closes the listening socket, and that is where the gap appears.
Graceful reload vs restart
Now the other side. systemctl reload php8.5-fpm sends USR2 to the master process: every worker finishes its current request and recycles with the new code. restart kills the master and starts from scratch, with a window where nobody answers.
Reload has limits worth knowing: it is not enough if you change listen, the pool user, or add a new extension, because those are only read when the master starts. For a version swap like this one, reload is enough.
What does not reload by itself: OPcache, preload and workers
OPcache and preload
With opcache.validate_timestamps=0, the normal setting in production, compiled code lives in memory and never learns that files changed. That is why the FPM reload is part of the change and not an optional extra: recycling workers refills OPcache. If you would rather not recycle yet, a controlled opcache_reset() does the same without touching the service.
opcache.preload is a different story: it runs once, when the master starts. If the preload script fails on the new branch, the service still comes up but without preloading, and you feel it on the first traffic spike. Watch out for the CLI too: it has its own OPcache and is no reference for what the web process sees. If you want to measure the real TTFB effect, the theory is in Laravel 13 page caching.
Queues, Horizon and the scheduler
Workers are long-lived processes: they keep running the old binary until you restart them.
php artisan queue:restart
On Horizon, php artisan horizon:terminate after changing the binary path in supervisor. And check the crontab, the classic oversight:
crontab -l | grep php
If it says /usr/bin/php8.2 artisan schedule:run, your scheduler stays on the old branch even though the site already moved. The same check applies to any systemd unit that launches PHP.
Canary and verification
Send a slice of traffic first
With both pools alive you can split by weight in nginx and see what happens before moving everything:
upstream php_app { server unix:/run/php/php8.2-fpm.sock weight=9; server unix:/run/php/php8.5-fpm.sock weight=1; }
Ten percent for half an hour, watching 5xx, TTFB and deprecation lines in the log, saves you the discovery at half past eleven. If something breaks, the weight goes back to 0 and that is that.
Post-change checklist
A protected endpoint of your own that returns PHP_VERSION is the fastest proof of what is actually serving. Add to it: diffing php -m against the inventory file, checking that storage/logs/laravel.log is not filling with deprecation notices, testing a file upload and a login by hand, and walking through the heaviest form in the app.
Rollback in one minute
Because the old branch was never removed, going back means reverting the destination and reloading:
fastcgi_pass unix:/run/php/php8.2-fpm.sock; · nginx -t && systemctl reload nginx
Then point cron and workers back at the old binary. Commit the nginx diff before you touch anything: rollback is exactly as fast as your last commit.
Automate the next switch
Every branch gets patches roughly every four weeks, so this repeats. It is worth turning into an idempotent script: check the current version, install the new branch, validate, reload, verify, notify. And do not confuse it with upgrading the operating system, which is a different procedure: for that one, see the Ubuntu 26.04 LTS guide.
Conclusion
Today's emergency patch and the branch change six months from now use the same mechanism: one socket, one reload, one canary. Knowing it is what separates "upgrading" from "praying while nginx returns 502". If this walkthrough helped, the blog has more server and zero-downtime deployment guides.

