Check what you're running
In a terminal over SSH:
php -vOr check the HTTP header (what an attacker sees):
curl -sI https://yourdomain.com | grep -i 'x-powered-by'Compare against the PHP2Shell fix versions:
Can't upgrade right now? Apply the interim mitigation
This is a stop-gap, not a fix. PHP's own advisory says updating is the only complete remediation. But if you can't touch production today, this closes most of the exposure in the meantime.
In php.ini or your PHP-FPM/web-server pool config (not ini_set() or .user.ini, those run too late to matter here):
session.upload_progress.enabled = 0On PHP 8.5, also set:
fatal_error_backtraces = 0Then restart every PHP worker (FPM, Apache mod_php, whatever you run), the setting only takes effect for new workers, not ones already running.
Application-level authentication does not block this vulnerability. PHP processes the malicious request before your app's code ever runs. "It's behind a login" doesn't help if the PHP-FPM/web-server port itself is reachable.
Back up everything
- Files (site root + uploads)
- Database (full dump)
- Confirm the backup restores before touching anything else.
tar czf backup-$(date +%F).tgz /path/to/site
mysqldump -u user -p dbname > db-$(date +%F).sqlTest on staging first
Never upgrade production directly. Copy the site to a staging host (or a local php -S / Docker container) at the target version and run it there first.
docker run --rm -v "$PWD":/app -p 8000:80 php:8.4-apacheUpgrade
How depends on your host:
- cPanel / shared hosting: MultiPHP Manager → select PHP 8.2/8.3/8.4.
- Managed host (WP Engine, Kinsta, etc.): the host's dashboard, or ask support to pin the version.
- VPS / apt:
apt install php8.4(adjust for your distro) and point the web server at the new PHP-FPM. - Docker: bump the base image (
php:8.4-apache).
The compatibility pass (the part people get stuck on)
PHP 8.x removed or changed a lot. Watch for:
- Removed functions (
each(),create_function(),mysql_*, curly-brace string offsets). Grep your codebase:grep -rEn 'each\s*\(|create_function|mysql_query|\$str\{' . implode()/array_key_exists()argument order,__autoload, andassert()behaviour changes.- WordPress: old themes/plugins that break on 8.x, update them first, then enable
WP_DEBUGand fix the notices. - Deprecation warnings (
libxml,FILTER_SANITIZE_STRING, dynamic properties), fix or suppress until updated.
Enable error reporting in staging and work through it page by page:
ini_set('display_errors', '1');
error_reporting(E_ALL);Deploy and verify
- Switch production to the new version.
- Re-check the header:
Confirm it's ≥ 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12.curl -sI https://yourdomain.com | grep -i 'x-powered-by' - Spot-check key pages (login, forms, checkout, admin).
- Remove the
X-Powered-Byheader entirely so you stop advertising the version, PHP:expose_php = Offinphp.ini, or strip it at the web-server/proxy layer.
Stay ahead
Subscribe to the PHP release feed and your CMS's security advisories. Or let 9line monitor it for you: 9line.dev/php-security.
Prefer a hand? We'll do the upgrade and compatibility pass and verify it.
Get my site secured →