Compare distribution backports, source builds, and upgrades for end-of-life PHP 5.4 to 8.1, and check code compatibility for PHP 8.4 or 8.5.
Running end-of-life (EOL) PHP during the PHP2Shell response puts you in a tight spot. While actively supported versions received official releases for CVE-2026-109618 and CVE-2026-109619 on 21 October 2026, older systems require a different strategy. At Brightline Logistics, the internal brightline-invoicing application runs on PHP 7.4 on Red Hat Enterprise Linux (RHEL) 8, while brightline-www runs on PHP 8.1 on Ubuntu 22.04. Both PHP 7.4 and 8.1 are end-of-life upstream, yet your team must secure both without breaking production.
Previous lesson: Detect PHP2Shell Exploitation Attempts in Your Logs | Next lesson: Harden PHP and PHP-FPM Configuration
Researchers traced the vulnerable code behind PHP2Shell back to PHP 5.4.0. However, the PHP project only publishes full packaged releases for actively supported branches.
Here is how upstream PHP handled older versions during the October 2026 release:
If your server runs PHP 8.1 or older, you cannot simply pull a new official release tarball or official Docker tag from the PHP project. You have to choose between three survival paths.
When an upstream PHP version reaches end-of-life, your options depend on how you installed PHP and whether your operating system (OS) is still under long-term support (LTS).
| Approach | How It Works | Best For | Key Drawback |
|---|---|---|---|
| Distro or LTS Vendor Patch | Your OS vendor backports the fix into their existing PHP package | Supported OS releases like Ubuntu 22.04 (brightline-www) | Only works if you use the OS vendor's default packages |
| Source Backport | You compile PHP yourself using the PHP security team's minimal patch | Custom builds on PHP 7.4, 8.0, or 8.1 where you cannot upgrade | You now own all future compilation and security patching |
| Upgrade to PHP 8.4 or 8.5 | You migrate the application to a modern, supported PHP branch | Long-term safety for legacy apps like brightline-invoicing | Requires code and dependency compatibility testing |
Linux distributions and commercial LTS vendors received the PHP2Shell patches in advance of the 21 October disclosure. If your OS release is still supported, the vendor often backports the security fix into the older PHP version they ship.
For example, Ubuntu 22.04 ships PHP 8.1. Even though PHP 8.1 is end-of-life at the PHP project, Canonical maintains the Ubuntu 22.04 package and issues security notices for it. This is the route brightline-www follows in Lesson 3.
Common Mistake: Assuming a third-party repository on a supported OS behaves like an official OS repository. If you installed PHP 7.4 on RHEL 8 using an unsupported third-party repository or a custom container image, Red Hat's patches will not cover it. Always check your vendor's current security notice to confirm coverage.
For PHP 7.4, 8.0, and 8.1 installations that do not receive vendor patches, the PHP security team provided minimal source backports. To use these, you must download the PHP source code for your version, apply the diff file for CVE-2026-109618 and CVE-2026-109619, and compile the binaries with your exact configuration flags.
Think of compiling from a source backport like machining a spare part for a discontinued truck engine. It gets the vehicle moving today, but you become the factory responsible for making every part that breaks tomorrow.
Only choose this path as a short bridge if an application is too fragile to upgrade immediately and has no vendor package fix.
Upgrading to an actively supported PHP version is the only permanent solution. Before you start an upgrade for brightline-invoicing, take the immediate precaution recommended by the Computer Emergency Response Team for the European Union (CERT-EU): isolate the application from public networks. Since brightline-invoicing is an internal tool on PHP 7.4, restrict access to your internal virtual private network (VPN) and apply the configuration mitigations from Lesson 4 while you prepare the upgrade.
Do not spend days upgrading a legacy app from PHP 7.4 to PHP 8.2 just because 8.2 looks closer. Look at the official PHP security support end dates per the PHP release cycle:
PHP 8.2 loses security support on 31 December 2026, so upgrading to it now leaves you back in an end-of-life state within weeks.
Target PHP 8.4 or PHP 8.5 for any upgrade project. PHP 8.4 has wide library support across the ecosystem and gives you protection until the end of 2028. PHP 8.6 is the newest release, but give frameworks and libraries a few months to add support before you move a legacy app straight to it.
Jumping from PHP 7.4 to PHP 8.4 introduces breaking changes, such as stricter type checks, removed functions, and the deprecation of dynamic class properties. You do not need to guess what will break in brightline-invoicing. You can scan the codebase and dependencies in minutes.
Before changing your application code, check if your third-party packages support PHP 8.4. Run Composer's why-not command in your project root:
bashCopy
This command outputs a list of packages in your composer.lock file that require an older PHP version. You can then test upgrading those specific packages in a separate git branch.
PHPCompatibility is a standard for PHP_CodeSniffer that detects deprecated or removed PHP features in your code. You can install it as a development dependency or run it from a separate tool directory so it does not conflict with your older project dependencies:
bashCopy
At the time of writing, the latest stable PHPCompatibility release (9.3.5) was published before PHP 8 and does not check PHP 8 changes. That is why the command above installs the 10.x pre-release, which does.
The scanner prints exact file names and line numbers that will fail on PHP 8.4.
Pro Tip: Use the --report=summary flag first on large legacy codebases. It gives you a quick count of errors and warnings by category so you can estimate how many hours the upgrade will take.
Once you know what needs to change, you do not have to edit hundreds of files by hand. Rector is a static analysis tool that automatically refactors PHP code to match newer language versions.
Install Rector as a development dependency of brightline-invoicing, then create a rector.php configuration file in the project root:
bashCopy
phpCopy
Always run Rector in dry-run mode first to preview the diff without modifying files:
bashCopy
Here is one change you will meet when moving from PHP 7.4 to PHP 8.4. Since PHP 8.0, declaring an optional parameter before a required one is deprecated, and PHP treats the optional parameter as required anyway. PHPCompatibility flags it, and you fix it by removing the misleading default value.
Before:
phpCopy
After:
phpCopy
After Rector applies its changes and you update your Composer dependencies, run your automated test suite against PHP 8.4.28 or later in your continuous integration (CI) pipeline before deploying to production.
Run an upgrade readiness check on one of your own PHP repositories (or a test project) without altering any production files:
composer why-not php 8.4 to identify any third-party packages that block a PHP 8.4 upgrade./tmp/phpcs-audit directory shown earlier and run phpcs with --standard=PHPCompatibility and --runtime-set testVersion 8.4 against your src or app directory.In the next lesson, Harden PHP and PHP-FPM Configuration, you will lock down your php.ini baseline, isolate PHP-FPM pools, and tighten web server rules to limit the impact of future vulnerabilities.
Was this lesson helpful?