Related posts
- XenForo on PHP 8.1 to 8.6: the same build six times
Six PHP series compiled with the same clang recipe and the same extensions, one XenForo forum with 100,000 posts, plain nginx, PHP-FPM and MariaDB. PHP 8.5 and 8.6 serve uncached pages 8-11 % faster than 8.1. 8.2, 8.3 and 8.4 tie, and 8.6 adds nothing over 8.5 yet.
- Dropping the packages: compiled nginx, PHP and Valkey, and what the migration tests broke
My setup script now builds nginx, PHP and Valkey from source and installs none of them from packages. Live servers migrate once, on --optimize. Testing that migration and a PHP downgrade chain found eight bugs, including a build log that grew to 1.7 TB. A day later, 1.22.1 dropped pre-compressed static files.
- Compiling Valkey, and the BOLT flag that gave my binaries an executable stack
Valkey from source was 35 % slower until I stopped passing CFLAGS on make's command line. Then its unit refused the BOLTed binary, which exposed an executable stack in my compiled PHP and Angie too. Plus nginx vs Angie, compiled the same way.
My servers still run the old way: Angie from its apt repository, PHP from the Sury repository, Valkey from Ubuntu’s package. The current version of my setup script compiles nginx, PHP and Valkey from source instead, and its
--optimizerun migrates an old host once: it builds everything while the packages keep serving, switches each service over, checks it, and only then removes the packages.I had tested that migration on one host: Ubuntu 26.04 with PHP 8.5. My live servers are not all like that. Some run Ubuntu 24.04, some PHP 8.3. So before touching any of them, I rebuilt the old setup with the previous release of the script and migrated it, for every PHP series from 8.1 to 8.6:
After each migration I ran the same checks: a walk through WordPress, XenForo and Chevereto as guest, member and admin, 78 security probes, and 109 cache-safety checks.
1. Cron ran PHP without its extensions#
During the switch, the migration hands
/etc/php/8.5/cliover to the new build. But/usr/bin/php8.5stays Sury’s binary until the old packages are removed. In that gap, Sury’s PHP starts with a configuration directory it no longer recognises: it loaded 2 of the 7 extensions the apps need.On a single-version host that gap lasts seconds. On the host with a second PHP version it never ends, because the Sury packages cannot go while 8.3 still uses them. My script runs WordPress and XenForo jobs every minute through
/usr/bin/php, and every one of them would have failed quietly.The fix: at the switch, the old binary is moved aside with
dpkg-divertand the new CLI takes its path. A package update during the gap still writes to the moved-aside copy, never to the path cron uses.2. Valkey did not compile on Ubuntu 24.04#
The 24.04 host built nginx and PHP fine, and stopped at Valkey:
Valkey re-declares
sprintfto mark it deprecated. With_FORTIFY_SOURCE=3, Ubuntu 24.04’s glibc definessprintfas a macro when clang compiles. Valkey’s Lua module includes the header after<stdio.h>, so the declaration turns into garbage. 26.04’s newer glibc does not use that macro, which is why I never saw it. The build now skips that one declaration wheresprintfis a macro. Ubuntu’s Valkey kept serving until then, so nothing broke. Afterwards the 7.2 package was replaced by 9.2.3. 61 MB of JIT buffer crashed PHP#
The 8 GB VMs found the strangest one. On PHP 8.1, pages loaded fine, but logins and form posts answered 502. The kernel log showed workers dying on a jump into JIT code:
On PHP 8.6 the service did not start at all:
mprotect() failed [22]. My script sizes OPcache at RAM/16 and the JIT buffer at an eighth of that. With 7.9 GB that is 495 MB and 61 MB, two odd numbers, and with huge pages the JIT region ends up badly aligned. I tested it on the 8.1 build, 40 rounds of five pages each:PHP 8.5 accepts either. The old Sury packages for 8.1, 8.2, 8.4 and 8.6 fail the same way. Both sizes are now rounded down to whole 2 MB. My live PHP servers have 32 GB or more and already used 512/64, so they were never affected.
4. “Reload: OK”, and PHP was down#
While I hunted that bug, the script itself took PHP down. It wrote the bad JIT size, tested the config once, and that test passed.
systemctl reloadreturned success. The re-executed master then exited half a second later. The report said “Reload: OK”.Reloads now wait three seconds and check that the master is still alive. A failed reload rolls back and starts the service again. And a PHP service that had crashed (not one I stopped myself) is started again once its new configuration passes
php-fpm -t.5. PHP 8.6 drops old names that extensions still use#
PHP 8.6 removed a pile of old compatibility macros:
zval_dtor,INI_STR,XtOffsetOfand others. The igbinary and redis extensions still use them. Sury patches its own packages for that, and now my build restores those names too. That was enough for igbinary.phpredis 6.3.0 needs more than that: its session code uses internals that 8.6 changed. So for now the script knows redis builds up to 8.5. An 8.6 host that needs redis (Chevereto, or XenForo with a Redis cache) is refused before anything is built, with that reason, and keeps its Sury PHP. An 8.6 host without them migrates.
Did it pay off?#
After the fixes, every host migrated cleanly and passed all checks, with zero segfaults. A reboot brought every service back. Then I measured what the migration buys. I rebuilt the old PHP 8.5 setup on the test box and ran 12 load tiers, 5 rounds, with the clock pinned at 3.6 GHz. Then I migrated, let the builds optimise themselves under traffic, rebooted, and ran the same tiers again. Medians of requests per second:
PHP needed 8-14 % less CPU per page on those tiers. Three member tiers moved less than the round-to-round spread, so I count them as ties.
The live servers get the fixed version on their next
--optimize. Without these test runs, the first real host to show these bugs would have been a live 24.04 server.