CloudLinux

Use PHP OPcache on cPanel hosting with CloudLinux PHP Selector

What PHP OPcache does, how to check it is enabled in CloudLinux PHP Selector, sensible OPcache options for WordPress, and how to clear it after deploying code.

IntermediatecPanel hosting with CloudLinux2 min read

Every time PHP runs a script, it first compiles the code. OPcache stores the compiled code in memory so the next request skips that step. It is one of the easiest speed gains for any PHP site, and on CloudLinux hosting you control it in PHP Selector.

Before you start

Check OPcache is enabled

  1. Go to cPanel → Software → Select PHP Version.
  2. In the extensions list, make sure opcache is ticked. It usually is by default.
  3. Confirm in WordPress under Tools → Site Health → Info → Server, or with a temporary phpinfo() page.

Options you may see

In the Options tab, depending on the server, OPcache settings may be editable:

OptionMeaningTypical value
opcache.memory_consumptionMemory for compiled code (MB)128
opcache.max_accelerated_filesNumber of scripts that can be cached10000 or more for WordPress with many plugins
opcache.revalidate_freqSeconds between checks for changed files2–60
opcache.validate_timestampsWhether to check files for changes at allOn (keep on for normal hosting)

Note: OPcache memory counts toward your account's CloudLinux memory limit. Very large values do not help small sites; keep defaults unless you know you need more.

After deploying code

With validate_timestamps on, OPcache notices changed files after revalidate_freq seconds. If an update does not seem to take effect:

  • Wait a minute, or
  • Switch PHP version and back in Select PHP Version, which restarts your PHP processes, or
  • Use a plugin or script that calls opcache_reset().

OPcache and page caching

OPcache speeds up every PHP request; LiteSpeed Cache avoids PHP entirely for cached pages. Use both (see LiteSpeed Cache and LSAPI explained).

Troubleshooting

Old code keeps running after an update

Timestamps validation is off or revalidate frequency is long. Reset OPcache as above.

Site errors after enabling OPcache

Very rare; usually a broken extension combination. Disable recently added extensions and test (see PHP extensions).

Frequently asked questions

Does OPcache need configuration to work?

No. Enabled with defaults, it already gives most of the benefit.

Is OPcache shared between accounts?

No. Each account's PHP processes have their own cache inside their own environment.

What about the JIT in PHP 8?

JIT helps CPU-heavy code more than typical websites. Leave it at the server default.

How do I see OPcache hit rates?

A small status script calling opcache_get_status() shows hits and memory use. Remove it after checking.

Does OPcache help WP-CLI or cron?

CLI runs usually do not keep OPcache between runs, so the benefit there is small; web requests benefit most.

Will changing PHP version clear OPcache?

Yes. Switching version restarts PHP processes, which starts with an empty cache.

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.