Upgrading PHP on a live site without breaking it
In this article10 sections
“Your site is running an outdated version of PHP.” If you manage a WordPress site, you have seen that notice, and probably scrolled past it. It is easy to ignore, because the site works. But PHP versions have a lifespan, and the day your version stops receiving security fixes is the day every newly found flaw in it stays open for good. Hosting companies eventually remove old versions too, sometimes with a few weeks’ notice, and a site that has never been tested on a newer PHP can break the day the old one disappears.
The risk in upgrading is real, though: plugins and themes written years ago can fail on newer PHP, and a white screen on a shop is expensive. This guide shows how to upgrade the way professionals do it: find what will break before you touch the live site, test the new version side by side, switch in a way that takes seconds, and have a one-line way back.
How long does a PHP version live?
The PHP project supports each release for two years of active development, then two more years of security fixes only, after which it receives nothing. You can see the exact dates for every version on the official supported-versions page at php.net, and you should check them yourself because they are the authority. As this guide is written, PHP 8.2 is in its security-only period and reaches the end of its life at the end of 2026, while 8.3, 8.4 and 8.5 are newer. In practice: a site on PHP 7 or 8.0 or 8.1 is already outside support and should move; a site on 8.2 should plan to move this year.
You do not need the newest version immediately. A version that is well into its supported life, such as the one currently recommended by your plugins, is a sensible target. The point is to be on a supported version and to move forward regularly, in small steps, instead of jumping five versions after years.
What changes between versions, and what breaks
Most PHP upgrades are uneventful for well-maintained code. The problems come from a few categories:
- Removed functions and features. Old code that uses functions that no longer exist causes fatal errors. These are usually in abandoned plugins and themes.
- Stricter type handling. Passing
nullto functions that expect strings now produces deprecation notices, and some mistakes that used to be silent are errors. - Dynamic properties. Since PHP 8.2, creating undeclared properties on objects is deprecated, which fills logs with notices for older plugins. It is noise today and will become an error in a future version.
- Changed defaults and extensions. An extension installed for the old version (for example
imagickorredis) must be installed for the new one too.
Deprecation notices do not break a site, but they are a warning of future breakage. Fatal errors do break it. Your job in testing is to find the fatals and note the deprecations.
Step 1: Inventory
Write down what you run. On the server:
php -v
php -m | sort > ~/php-modules-old.txt
wp core version
wp plugin list --fields=name,status,version,update
wp theme list --fields=name,status,version,update
For a Laravel application, look at composer.json (the php requirement and each package) and run composer outdated. For each plugin, theme or package, the questions are: is it updated, is it actively maintained, and does its page or changelog say which PHP versions it supports? Anything abandoned (no updates in over a year or two) is a likely casualty. Replace it before the upgrade, not after.
Step 2: Scan the code for compatibility problems
An automated checker finds many problems without running the site. PHP_CodeSniffer with the PHPCompatibility rules reads your code and reports what will fail on a target version:
composer global require --dev phpcompatibility/phpcompatibility-wp squizlabs/php_codesniffer
phpcs -p wp-content --standard=PHPCompatibilityWP --runtime-set testVersion 8.3- --extensions=php --ignore=*/node_modules/*,*/vendor/*
Set testVersion to your target (8.3- means 8.3 and later). Read the errors: those are things that will break. Warnings are things to watch. This is a good guide, not a guarantee, because it cannot see everything that happens at run time, so the real test is next.
Step 3: Make a staging copy and test the new version there
Never experiment on the live site. Make a copy on a staging address (see a safe WordPress workflow with staging and rollback) and run it on the new PHP.
On a VPS you manage, you can run two PHP-FPM versions side by side. On Ubuntu 24.04 the repository provides 8.3; for other versions use a maintained PHP package repository. Install the new version and the same extensions:
sudo apt install php8.4-fpm php8.4-mysql php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip php8.4-gd php8.4-intl
php8.4 -m | sort > ~/php-modules-new.txt
diff ~/php-modules-old.txt ~/php-modules-new.txt
The diff shows extensions you have on the old version but not on the new one. Install them. Copy your PHP settings (memory limit, upload size, OPcache) to the new version’s configuration, because they do not carry over by themselves. Point the staging site at the new socket in the NGINX configuration:
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
On cPanel, use MultiPHP Manager to set the PHP version for the staging domain only. On Plesk, open the domain’s PHP Settings. On CloudLinux, use the PHP Selector. All of them let you test one site on a new version while the others stay put.
Step 4: Test what matters
With staging on the new version and error logging on (WP_DEBUG_LOG for WordPress, which writes to wp-content/debug.log, with display switched off), go through the site as a user would:
- Pages and posts, the home page, archives, search, and a few old pages built with a page builder.
- Forms: contact forms must send mail, and you should receive it.
- Login, registration and the admin area, including editing and saving a post and updating a plugin.
- Checkout, if you sell: add to cart, pay (in test mode), receive the confirmation.
- Scheduled jobs and imports.
- Media: uploading an image and generating thumbnails (needs
gdorimagick).
Then read the log:
tail -n 50 wp-content/debug.log
grep -c "Deprecated" wp-content/debug.log
grep "Fatal" wp-content/debug.log
Fix or replace anything that produces a fatal error. Deprecations you can note and watch.
Step 5: Switch the live site
When staging is clean, schedule the change for a quiet time and take a backup first (files and database). On a VPS with NGINX, the switch is one line:
# before
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
# after
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
Then:
sudo nginx -t && sudo systemctl reload nginx
Reload, load the site, and watch the logs immediately. Rollback is the same line the other way and another reload, which takes seconds, as long as you leave the old PHP version installed and running. On cPanel or Plesk, rollback is changing the version setting back.
Step 6: After the switch
- Watch the logs for 48 hours: the PHP-FPM log, the web server error log and the application log.
- Check with a monitor that the home page and checkout still answer (see monitoring a small server).
- Re-check OPcache settings and memory use. A newer PHP may use memory differently; see the SiteHarbour guide to PHP-FPM workers on limited RAM.
- Remove the old version later, after a week or two without problems, so that you are not patching two.
Common problems
- A white screen right after the switch: read the error log; it is almost always one plugin or a missing extension. Deactivate the plugin by renaming its folder, or install the extension.
- A missing extension:
php -mon both versions makes this easy to catch beforehand. - Composer packages that need a newer or older PHP:
composer why-not php 8.4tells you which packages block the version. - Old themes or plugins with no update available: replace them. Staying on an unsupported PHP to keep an abandoned plugin is trading a visible problem for an invisible one.
When it is worth getting help
For a small brochure site, this is an afternoon’s work. For a shop, a membership site, or a site with years of plugins and a custom theme, a careful upgrade with a compatibility scan, a staging test, and a rehearsed rollback is worth having done by someone who has done it many times.
I upgrade PHP on WordPress, Laravel and custom PHP sites across cPanel, Plesk and plain Linux servers. You can see my profile on Upwork, or read about WordPress and Laravel care.