PHP 7 and OPcache: how they speed up your website

By Unlimited Published 7 September 2016 Updated 15 April 2026 5 min reading time
PHP 7 and OPcache: how they speed up your website

If your website feels slower than it should, the version of PHP your server is running could be part of the problem. Switching to PHP 7 and enabling OPcache together is one of the most effective ways to reduce page load times without touching a line of your site’s code.

This post covers what PHP 7 changed, how OPcache works alongside it, and what kind of performance difference you can realistically expect.

What changed in PHP 7

PHP 7 was a major release that rewrote large parts of the PHP engine. The most significant change was a new execution engine called PHPNG (PHP Next Generation), which processes requests more efficiently and uses less memory doing it.

In practical terms, PHP 7 is roughly twice as fast as PHP 5.6 on most workloads. That is not a marginal improvement. Benchmarks from the PHP development team showed WordPress running more than twice as many requests per second on PHP 7 compared to PHP 5.6, with memory consumption dropping at the same time.

For sites running content management systems like WordPress, Drupal or Joomla, the difference is noticeable. More requests handled per second means your server copes better under load, and individual page responses arrive faster.

What OPcache does

Every time PHP processes a page request, it reads your PHP files, compiles them into a format the server can execute (called bytecode), runs them, and discards the result. The next request starts the same process again from scratch.

OPcache breaks that cycle. It stores the compiled bytecode in memory after the first request, so subsequent requests skip the compilation step entirely. The server reads from memory rather than recompiling the same files repeatedly.

The result is a measurable reduction in CPU usage and faster response times, particularly on sites with many PHP files. A WordPress installation, for example, loads dozens of PHP files on every page request. OPcache means those files are compiled once and reused.

Tip: OPcache is bundled with PHP 5.5 and later, so no separate installation is needed. It does need to be enabled in your PHP configuration, which your hosting control panel can handle.

PHP 7 and OPcache working together

PHP 7 and OPcache address different parts of the same problem. PHP 7 makes the execution engine faster. OPcache removes the compilation overhead that happens before execution even begins. Running them together compounds the benefit.

On a typical shared hosting environment, a WordPress site on PHP 5.6 without OPcache might handle 50 to 100 requests per second before the server starts to struggle. The same site on PHP 7 with OPcache can handle several times that number. The exact figures depend on your theme, plugins and database queries, but the direction of the improvement is consistent.

For high-traffic sites, this headroom matters. For smaller sites, the benefit shows up as faster individual page loads rather than capacity under load.

How to check and change your PHP version

Most hosting control panels let you change your PHP version per domain. In cPanel, the option is usually found under Software as Select PHP Version or MultiPHP Manager. In Plesk, you can set the PHP version from the domain settings page.

Before switching, check that your plugins and themes are compatible with the version you are moving to. Most actively maintained WordPress plugins support PHP 7.4 and above, but older or abandoned plugins may not. Running a staging site first is a sensible precaution if you are unsure. Our guide to WordPress staging sites covers how to set one up.

For step-by-step instructions on changing your PHP version in cPanel, the UWH knowledgebase guide on changing PHP version walks through the process.

Checking whether OPcache is active

You can confirm OPcache is running by creating a phpinfo() file on your server. This outputs a full list of your PHP configuration, including which extensions are loaded and their current settings. Look for a section labelled Zend OPcache. If it appears, OPcache is active.

The knowledgebase guide on creating a phpinfo file explains how to do this safely and how to remove the file afterwards. Leaving a phpinfo() file publicly accessible is a security risk, so delete it once you have confirmed what you need.

If OPcache is not showing as active, contact your host. On most managed hosting plans it can be enabled without any server-level access on your part.

Other factors that affect PHP performance

PHP version and OPcache are two levers, but they are not the only ones. A few other settings influence how efficiently PHP runs on your server.

These are the main configuration values worth reviewing:

  • memory_limit. The maximum memory a single PHP process can use. Too low and scripts fail; too high and a runaway script can affect other sites on the server.
  • max_execution_time. How long a PHP script is allowed to run before the server terminates it. The default of 30 seconds is fine for most sites.
  • opcache.memory_consumption. The amount of shared memory allocated to OPcache. The default is 128MB, which is sufficient for most sites, but larger applications may benefit from more.
  • opcache.max_accelerated_files. The maximum number of PHP files OPcache will store. If your application has many files and this limit is too low, some will not be cached.

For WordPress sites specifically, increasing the memory limit is a common fix for sites that throw memory exhaustion errors after adding plugins. The guide to increasing the WordPress memory limit covers the options available to you.

PHP version and OPcache are a strong starting point for improving server-side performance. Switching to PHP 7 or above and confirming OPcache is active costs nothing and requires no changes to your site’s code. For most sites, the improvement is immediate.

If you are on PHP hosting with UWH, OPcache is available across our plans. Check your current PHP version in cPanel or Plesk and update it if you are still running an older release.

If you have questions about your PHP configuration or want advice on the right settings for your site, get in touch with our team.

You May Also Like

Related articles you might find interesting.

Plesk

What is Plesk Hosting?

3 min read. 17 February 2020. Lee.
Plesk

What’s new in Plesk Obsidian?

3 min read. 10 December 2019. Lee.
Web Hosting

Critical migration mistakes and how to avoid them

4 min read. 28 October 2019. Lee.

Ready to get started?

Launch your website with our reliable cPanel hosting with unlimited bandwidth and expert support.

Get cPanel Hosting

Need a domain?

Find and register the perfect domain name for your website.

Search Domains