🇺🇸 Welcome from the USA! We have special plans for you.
View US Hosting Plans →

Configure PHP OPcache for better performance

📅 15/06/2026 ⏱ 5 min de lectura
PlatiniumHost

Escrito por

Luis Contreras · CEO & Fundador · +24 años en hosting

Introduction to PHP OPcache and its Importance

In the world of web hosting, speed and performance are critical factors for the success of any site. A fast website not only improves user experience but also has a positive impact on SEO and conversion rates. At PlatiniumHost, we strive to offer the best tools to optimize the performance of your projects, and PHP OPcache is one of the most powerful and easy to implement.

PHP OPcache is an extension designed to improve the performance of PHP applications by storing precompiled PHP code in the server's memory. This eliminates the need for the server to compile the same PHP code over and over again with each request, significantly reducing processing time and server load.

Tip: Activating PHP OPcache is one of the simplest and most effective performance optimizations you can make for your PHP website, regardless of whether you use WordPress, Joomla, or a custom application.

What is PHP OPcache?

When a PHP script executes, it is first parsed, compiled into an intermediate code (bytecode or opcode), and then executed. Without OPcache, this parsing and compilation process occurs every time the script is requested. This consumes CPU resources and time, especially on sites with high traffic or complex applications.

PHP OPcache acts as an accelerator. Once a PHP script is compiled for the first time, OPcache stores its bytecode in the server's shared memory. Subsequent requests for the same script can use the stored bytecode directly, skipping the parsing and compilation stages. This results in much faster script execution and lower server load.

Why Activate OPcache on PlatiniumHost?

At PlatiniumHost, we understand that every millisecond counts. By activating OPcache, websites hosted on our infrastructure experience a noticeable improvement in loading speed. This translates into a better experience for your visitors, which can lead to higher user retention and better search engine rankings.

For popular applications like WordPress, Joomla, Drupal, or Magento, which rely heavily on PHP, OPcache is almost a necessity. It reduces server load, allowing your hosting plan to handle more visitors simultaneously without compromising performance. It's a low-effort, high-impact optimization that benefits all our customers.

Prerequisites for Configuration

Before proceeding with OPcache activation, make sure you meet the following requirements:

  • Have access to your PlatiniumHost cPanel control panel.
  • Your website must be using a compatible PHP version. OPcache was natively included starting from PHP 5.5, so if you are using a modern PHP version (PHP 7.x, 8.x), it will already be available.

How to Activate PHP OPcache in cPanel (Step by Step)

Activating PHP OPcache in cPanel is a simple process that can be completed in a few minutes. Follow these steps:

  1. Access your cPanel: Log in to your cPanel control panel provided by PlatiniumHost.
  2. Find the PHP Selector: In the 'Software' or 'Programs' section, find and click on 'Select PHP Version' or 'MultiPHP INI Editor'. The exact name may vary slightly depending on your server configuration.
  3. Select the PHP Version: If you haven't already, make sure you are using a modern PHP version (we recommend PHP 7.4 or higher for optimal performance). If your site requires a specific version, make sure it is PHP 5.5 or higher.
  4. Activate the OPcache Extension: In the list of PHP extensions, look for 'opcache'. Check the box next to 'opcache' to activate it.
  5. Save Changes: Scroll down and click the 'Save' or 'Apply' button to save the changes.

Once you have saved the changes, OPcache will be active for the selected PHP version and will begin to accelerate your PHP scripts.

Important: If your site uses a very old PHP version (prior to PHP 5.5), OPcache will not be available. Consider updating your PHP version to benefit from this and other performance and security improvements.

Advanced OPcache Configuration (Optional)

Although basic OPcache activation already provides a great performance boost, you can adjust some parameters to further optimize its operation through the php.ini file. This can be done in cPanel through the 'MultiPHP INI Editor' or by directly editing the php.ini file in the root of your domain or subdomain.

Common OPcache Parameters

  • opcache.enable = 1: Enables or disables OPcache. (0 to disable, 1 to enable).
  • opcache.memory_consumption = 128: The amount of shared memory to store opcodes (in megabytes). A value of 128 MB is a good starting point for most sites.
  • opcache.interned_strings_buffer = 8: The amount of memory to store interned strings (in megabytes). Interned strings are strings that are used repeatedly in the code.
  • opcache.max_accelerated_files = 10000: The maximum number of scripts that can be stored in the cache. Adjust this value according to the number of PHP files in your project.
  • opcache.revalidate_freq = 0: How often (in seconds) the system will check for updates to PHP scripts. If set to 0, OPcache will always check if the file has changed before using the cached version. For production environments where files do not change often, a value like 60 seconds can improve performance, but in development, 0 is better.

You can add or modify these directives in the 'MultiPHP INI Editor' in cPanel. Select your PHP version and then the 'Basic INI Editor' or 'Advanced INI Editor' tab to add or modify the lines.

opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=20000
opcache.revalidate_freq=0
opcache.validate_timestamps=1
opcache.fast_shutdown=1
Tip: If your website is very large or has high traffic, consider increasing opcache.memory_consumption and opcache.max_accelerated_files. However, monitor memory usage to avoid running out.

Verifying OPcache Activation

To confirm that PHP OPcache is working correctly, you can create a phpinfo.php file in the root of your domain (or in the public_html folder) with the following content:

<?php
phpinfo();
?>

Then, access this file from your browser (for example, https://yourdomain.com/phpinfo.php). Look for the 'OPcache' section. You should see 'Opcache' as 'Up and Running' or in the settings, opcache.enable should be set to 'On'. If you see it, congratulations, OPcache is active and working!

Conclusion

Activating and configuring PHP OPcache is one of the simplest and most effective performance optimizations for any PHP website. By reducing CPU load and accelerating script execution, it not only improves your site's speed but also optimizes the use of your hosting plan's resources at PlatiniumHost.

If you have any questions or need additional help with OPcache configuration or any other performance optimization, do not hesitate to contact our PlatiniumHost technical support team. We are here to help you get the most out of your web hosting.

💬 ¿En qué podemos ayudarte?

Selecciona un agente de soporte

¿Hablamos?