PHP version and OPcache for speed

php, opcache, select php version, performance, wordpress, upgrade · 0 found this helpful

PHP is the language WordPress and many other sites run on. Newer PHP versions run the same code faster and use less CPU. Moving up a version is one of the cheapest speed gains, if you test first.

Why newer is faster

Each PHP release runs the same code with less work. Moving from an old version to a current one can cut page build time noticeably. The exact gain depends on your site. Old versions also stop getting security fixes, so staying on them is a risk.

The PHP version screen offers 5.6 through 8.5. Pick the newest version your plugins support, not just the newest on the list. For most WordPress sites today that's 8.3 or 8.4.

Before you change

  1. Make a backup. See Download a backup copy.
  2. Update WordPress, plugins, and theme first. Old plugins are the main reason a PHP upgrade breaks a site.
  3. Use staging if you have it. See Staging sites.

Change the PHP version

  1. Go to Account → Hosting → your site → Performance → Choose PHP for each site.
  2. Each site has its own card, so you can set the version for each one separately.
  3. Choose a new PHP version on the site's card and click Save. We check the site still loads, and put the old version back if it doesn't.
PHP for each site
  1. Check your site: front page, login, a form, checkout.

More detail: Change PHP version and extensions and Pick a PHP version for WordPress.

If the site breaks

Symptom Fix
White screen or a 500 error Switch back to the old version. Then find the plugin that fails. See Fix the WordPress white screen
"Deprecated" notices in the log Not an error. They mean a plugin uses old code. Update it. See Read and fix common PHP errors
Missing extension errors Turn on the extension under Performance → Extensions. Common ones are mysqli, curl, mbstring, gd, zip, intl

Switching back takes a few seconds. Nothing is lost.

What OPcache does

PHP normally reads and translates your code files on every request. OPcache keeps the translated code in memory, so PHP doesn't repeat the work. This usually speeds up pages a lot, and costs nothing.

  • OPcache is on by default.
  • Check it under Performance → Extensions (opcache is ticked) or on a phpinfo() page. Look for opcache.enable set to On.
  • After you change code files, OPcache picks up the change within about two seconds.

Settings that help or hurt

Setting Where Notes
memory_limit Performance → Choose PHP for each site → PHP settings → Memory per request 256M works for most WordPress sites. Higher doesn't make it faster. See Raise the WordPress memory limit
max_execution_time Performance → Choose PHP for each site → PHP settings → Time limit per request Long limits let stuck scripts use resources. Keep defaults unless an import needs more
max_input_vars Performance → Choose PHP for each site → PHP settings → Form fields per request Raise only if a big menu or settings page loses values

See Change PHP settings.

Check the result

Test before and after. See Test your site's speed properly. Also check Resource usage for CPU. See Read your Resource Usage page.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.