- Run a PHP version that still gets security fixes. An unsupported version is an unpatched one.
- Check yours in the WordPress admin under Tools, Site Health, Info, Server. No plugin needed.
- Newer PHP runs the same code faster, so you gain speed for the cost of the upgrade alone.
- Test on a staging copy first. Almost every upgrade problem is one abandoned plugin, and staging is where you want to find it.
- If a plugin blocks the upgrade, replace the plugin. Staying on unsupported PHP to keep it is the worse trade.
Which PHP version should WordPress run on?
Run the newest PHP version that your plugins and theme support and that still gets security updates. Each PHP release gets two years of bug and security fixes, then one year of security fixes only, then nothing. After that date, any new flaw in PHP itself stays unfixed on your server.
| Version status | What it means for you |
|---|---|
| Actively supported | Bug fixes and security fixes. The version to be on |
| Security support only | Security fixes only. Fine, but plan the next move |
| End of life | No fixes at all. Upgrade is the only response |
| PHP 7.x | All branches are end of life. Upgrade regardless of anything else |
Check the current dates at php.net/supported-versions before deciding. They move every year.
"It still works" does not mean "it is supported"
An end-of-life PHP version keeps running perfectly, and nothing warns you it has stopped getting patches. A flaw found after the end date is never fixed.
# From the command line
php -v
# The version PHP-FPM is actually serving, which can differ from the CLI
php-fpm8.3 -v
curl -sI https://example.com/ | grep -i x-powered-by
# Via WP-CLI
wp eval 'echo PHP_VERSION . PHP_EOL;'
# In the admin: Tools, Site Health, Info, ServerHow much faster is a newer PHP version?
Enough to justify the upgrade on its own. Every release since PHP 7.0 has run the same code faster. On WordPress that means fewer CPU seconds per request, so the same server handles more visitors at once.
Measure it on a staging copy of your own site rather than trusting a benchmark, because your plugins decide the real number.
# Time to first byte, cache bypassed, ten runs
for i in $(seq 1 10); do
curl -s -o /dev/null -w '%{time_starttransfer}\n' \
"https://staging.example.com/?nocache=$RANDOM"
done | awk '{s+=$1; n++} END {printf "avg TTFB: %.3fs over %d runs\n", s/n, n}'
# CPU time for a WordPress bootstrap
time wp eval 'echo "ok";'?nocache= parameter gets past the page cache, so you time PHP rather than a stored page.Leave the JIT off
PHP 8's JIT (a compiler for number-heavy code) does little for a web request, which spends most of its time waiting on the database and disk. It has also caused hard-to-trace memory faults on PHP 8.3, so we keep it off on our platform. Keep OPcache (PHP's compiled-code cache) on: that is the large, reliable win.
How do I upgrade PHP safely?
Always on a staging copy first. The upgrade takes minutes. Finding the broken plugin on the live site takes much longer and costs you visitors while you look.
- 1Update everything else first: WordPress core, every plugin and the theme, as you would when patching the server underneath. Half of PHP compatibility problems go away here, because the fix was already released.
- 2Look for abandoned plugins. Anything not updated for over a year is the likely blocker. Find a replacement before the upgrade, not during it.
- 3Clone the site to staging and switch that copy to the new PHP version.
- 4Run a compatibility scan with PHPCompatibility, then use the site for real: checkout, forms, admin, media upload and every integration.
- 5Watch the error log while you test. PHP 8 turned many old notices into fatal errors, so a warning you ignored for years may now be a white screen.
- 6Switch production in a quiet window, and keep the old version installed so you can switch back in seconds.
# Ubuntu, using the ondrej PPA
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php8.3-fpm php8.3-mysql php8.3-curl php8.3-gd \
php8.3-mbstring php8.3-xml php8.3-zip php8.3-intl php8.3-bcmath php8.3-imagick
# Both versions installed side by side. Point the site at the new socket:
# fastcgi_pass unix:/run/php/php8.3-fpm.sock;
sudo nginx -t && sudo systemctl reload nginx
# Switching back is one line and a reload
# fastcgi_pass unix:/run/php/php8.1-fpm.sock;Install the extensions too
php8.3-fpm on its own is a PHP with almost nothing in it. WordPress needs mysql, curl, gd or imagick, mbstring, xml and zip at minimum. Without mbstring, characters break; without gd, image resizing fails. Check with php -m before you switch anything.
# PHPCompatibility via composer
composer global require phpcompatibility/php-compatibility
phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 8.3 \
--extensions=php --ignore='*/vendor/*,*/node_modules/*'
# Or from inside WordPress
wp plugin install php-compatibility-checker --activate
# Plugins not updated in over a year: the usual blockers
wp plugin list --fields=name,version,update,statusWhat breaks when upgrading to PHP 8?
PHP 8 is stricter than 7.x, so sloppy code it used to tolerate now stops with a fatal error. Five patterns cause most of what you will see, and all five come from plugin or theme code, not WordPress core.
| Error | Cause | Fix |
|---|---|---|
| Uncaught TypeError: passed null | Passing null where a string was expected | Update the plugin; it is a known PHP 8 change |
| Cannot use function return value in write context | Old syntax removed in PHP 8 | The plugin needs updating |
| Call to undefined function | An extension is not installed | Install the missing php8.3-* package |
| Deprecated: Required parameter follows optional | Argument order PHP 8 rejects | Update the plugin |
| White screen, nothing in the browser | A fatal error with display_errors off | Read the PHP error log, not the page |
The pattern is the same each time: the plugin needs an update. If there is none, that plugin is the problem.
# Follow the PHP error log while you reload the page
sudo tail -f /var/log/php8.3-fpm.log
sudo tail -f /var/log/nginx/error.log
# Turn on WordPress debug logging (staging only)
# in wp-config.php:
# define('WP_DEBUG', true);
# define('WP_DEBUG_LOG', true);
# define('WP_DEBUG_DISPLAY', false);
tail -f wp-content/debug.logOne abandoned plugin should not pin your PHP version
If a plugin only runs on unsupported PHP, keeping it means running unpatched PHP on a public server. Replace the plugin, or pay someone to fix it.
Once you are on a current version, the next gain comes from how PHP is configured. Tuning PHP-FPM for performance covers worker counts and OPcache. On G7Cloud you change a site's PHP version in the dashboard (7.4 to 8.4 are offered), and switching back is the same setting; the site restarts for a few seconds each time. See our WordPress hosting.
Frequently asked questions
What PHP version should I use for WordPress?
The newest version that still gets security support and that your plugins and theme work with. Check the current dates at php.net/supported-versions. Anything on PHP 7 is end of life and should be upgraded whatever else is going on.
How do I check which PHP version my WordPress site uses?
In the admin, go to Tools, Site Health, Info, and open the Server section. On the command line, php -v shows the command-line version, which often differs from the web server's. curl -sI https://yoursite.com | grep -i x-powered-by shows the version serving your pages.
Will upgrading PHP break my WordPress site?
It can, and it is almost always one abandoned plugin, not WordPress itself. Update everything first, test on a staging copy, and keep the old PHP version installed so switching back takes one config line and a reload.
Is PHP 8 faster than PHP 7 for WordPress?
Yes, on the same unchanged code. The gain shows as less CPU per request, so the same server handles more visitors at once. Measure it on a staging copy of your own site, since your plugins decide the real figure.
Should I enable the PHP JIT for WordPress?
No. A WordPress request spends most of its time on the database and disk, so the JIT gains little, and it has caused memory faults on PHP 8.3. Keep OPcache on and the JIT off.
What PHP extensions does WordPress need?
At minimum mysqli, curl, gd or imagick, mbstring, xml and zip. Many plugins and WooCommerce also need intl and bcmath. Installing php8.3-fpm alone leaves you without them, so check what is loaded with php -m before you switch the site over.
About G7Cloud Engineering
Articles written by the engineers who build and run G7Cloud: UK managed hosting and the AI Website Builder. We write about what we operate every day: containers, backups, databases, and the small-business websites that run on them.
More about G7Cloud →