Running WordPress on an old PHP version (7.4 or earlier) means slower pages and no security fixes: PHP 7.4 reached end of life in November 2022, and 8.0 and 8.1 are end of life too. WordPress core runs well on PHP 8.2 and 8.3, but old plugins and themes may not. Here’s how to upgrade without surprises.
Why upgrade
- Security: unsupported PHP versions get no security patches.
- Performance: PHP 8.x is noticeably faster for WordPress than 7.x, which lowers TTFB and server load. See WordPress TTFB.
- Compatibility: new plugin versions increasingly require PHP 8.x.
What breaks in PHP 8
Most issues come from old code:
| Change | Typical error |
|---|---|
Removed functions (create_function, each, …) |
Call to undefined function |
| Stricter type handling | TypeError: Argument … must be of type … |
| Many warnings became errors | Uncaught Error: Attempt to assign property on null |
| Changed string/number comparisons | Subtle logic bugs |
| Deprecated dynamic properties (8.2) | Deprecated: Creation of dynamic property (warning only) |
Deprecation notices are just warnings, and can be ignored on production (log them, don’t display them). Fatal errors must be fixed before switching.
Step 1: check what you run
php -v
wp core version
wp plugin list --fields=name,version,update_version,status
wp theme list
Update everything first. Many compatibility fixes are already in newer plugin versions. Remove plugins that are inactive or abandoned (no update for a year or more).
Step 2: scan the code (optional, useful for custom code)
The PHPCompatibility standard for PHP_CodeSniffer flags incompatible code:
composer global require phpcompatibility/php-compatibility squizlabs/php_codesniffer
~/.config/composer/vendor/bin/phpcs --config-set installed_paths ~/.config/composer/vendor/phpcompatibility/php-compatibility
~/.config/composer/vendor/bin/phpcs -p wp-content/plugins/my-custom-plugin --standard=PHPCompatibility --runtime-set testVersion 8.3
Focus on your custom plugins and theme. Popular plugins are maintained by their authors.
Step 3: install the new PHP side by side
On Ubuntu with the ondrej/php PPA (or Debian’s sury repository), you can install several versions:
sudo add-apt-repository ppa:ondrej/php && sudo apt update
sudo apt install -y php8.3-fpm php8.3-{mysql,curl,gd,imagick,intl,mbstring,xml,zip,opcache,redis,bcmath}
Copy custom settings (memory limit, upload size, OPcache) from the old version’s php.ini and pool config. See PHP versions on Ubuntu and PHP extensions.
Step 4: test on staging
Point a staging copy at the new PHP-FPM socket, and test:
- the front end (home, posts, archives, search);
- admin screens, the editor, media upload;
- forms, checkout and payment (in test mode), and membership logins;
- cron jobs and background tasks (
wp cron event run --due-now); - the PHP error log, while you click around.
See WordPress staging site and WordPress debug mode.
Step 5: switch production
In the site’s Nginx server block, change the socket:
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
sudo nginx -t && sudo systemctl reload nginx
Also switch the CLI PHP used by WP-CLI and cron (sudo update-alternatives --set php /usr/bin/php8.3), and update any cron entries that call a specific PHP binary.
Watch the error log closely for the first hours:
sudo tail -f /var/log/nginx/error.log
Rolling back
Because the old PHP-FPM version is still installed, rollback is a one-line change: point fastcgi_pass back to the old socket, and reload Nginx. Once the new version has run cleanly for a while, remove the old packages.
If a plugin isn’t compatible
- Check for an update or a beta version that adds PHP 8 support.
- Ask the developer, or check the support forum.
- Replace it with a maintained alternative.
- Only as a temporary measure, keep that site on an older PHP pool while you replace the plugin, but don’t stay on an unsupported version for long.
Quick reference
| Step | Command / action |
|---|---|
| Current version | php -v, Site Health → Info → Server |
| Update first | wp core update && wp plugin update --all |
| Scan custom code | phpcs --standard=PHPCompatibility --runtime-set testVersion 8.3 |
| Install side by side | apt install php8.3-fpm php8.3-… |
| Switch | fastcgi_pass unix:/run/php/php8.3-fpm.sock; |
| Roll back | point back to the old socket |
Related: update WordPress safely and WordPress plugin conflicts.