How to Disable OpCache Tutorial For WebHostingM Customers & Resellers Make it Rain Paper

  • PHP, OpCache, Performance Optimization
  • 0

OpCache is a PHP extension that optimizes script execution by caching precompiled bytecode in memory. While OpCache can enhance performance, some applications may require it to be disabled. Disabling OpCache is especially important for resellers working with WHMCS, as OpCache can cause segmentation faults and errors if improperly configured with WHMCS-specific processes.

Important Note for WHMCS Users

OpCache may interfere with WHMCS operations and payment gateways like PayPal, leading to errors such as “Gateway Activation Failed.” Additionally, enabling OpCache can lead to segmentation faults due to cached data conflicts, often signifying a PHP extension issue. Disable OpCache to avoid these errors and ensure stable WHMCS performance.

Before proceeding with OpCache configuration changes:

  • Test these steps in a non-production environment first
  • Backup your current OpCache configuration
  • Check OpCache's official documentation for the latest instructions
  • Ensure you have selected an appropriate maintenance window

Method 1: Using cPanel's PHP Selector (CloudLinux Servers)

PHP is fine-tuned with the php.ini file. This is necessary because PHP's defaults are neither secure nor optimal.

cPanel provides defaults that are more secure but still have the most used features active.

However, each server is different, and you are likely to find that you need to change some of the PHP options.

On WebHostingM servers with CloudLinux, you can use PHP Selector in cPanel to manage PHP extensions like OpCache for individual domains.

  1. Log into your cPanel interface.
  2. Under the Software section, select Select PHP Version.
  3. Locate Current PHP Version and search for the “OpCache” checkbox.
  4. Uncheck the box to disable OpCache.
  5. Click Save to apply changes.

Note: If you are on a web hosting plan using MultiPHP Manager, avoid using PHP flags in .htaccess. Instead, create a custom php.ini file in the account directory or use the MultiPHP INI Editor under Software in cPanel. Save your desired settings, and they'll be written to php.ini, .user.ini, or .htaccess files as supported.

Method 2: Disabling OpCache with Custom php.ini (For VPS or Dedicated Servers)

If you have root access on a VPS or dedicated server, you can create a custom php.ini file for the account to disable OpCache:

  1. Open your terminal and navigate to the website's home directory.
  2. Create or edit the php.ini file:
sudo vim /path/to/your/php.ini
  1. Add the following line to disable OpCache:
opcache.enable=0
  1. Save and exit the file.

To verify changes, create a new PHP file (e.g., phpinfo.php) and add:

<?php
phpinfo();
?>

Access this file in a browser (e.g., https://example_domain.com/phpinfo.php) and check for “OpCache” in the output to confirm it's disabled.

Method 3: Disabling OpCache in Plesk (For Plesk Users)

If you're using Plesk, you can disable OpCache from within the Plesk interface:

  1. Log into your Plesk control panel.
  2. Navigate to Domains > example_domain.com > Dashboard and locate the PHP settings.
  3. Find opcache.enable and set it to “off.”
  4. Verify that the disable_functions setting doesn't contain OpCache functions, such as opcache_get_status.

Note: OpCache statistics can be found at Domains > example.com > PHP Settings, under the phpinfo() page, showing cache hits and misses.

Segmentation Faults and Other WHMCS Issues with OpCache

WHMCS users may encounter fatal errors or segmentation faults due to stale OpCache data, often caused by incompatible OpCache configurations. For example:

Fatal error: Uncaught Error: Class "Laminas\ZendFrameworkBridge\Autoloader" not found...

To resolve this, deactivate OpCache in your PHP configuration, then reload your WHMCS setup. These errors often result from PHP's attempt to access stale cached data, which OpCache can exacerbate.

Advanced Troubleshooting

If errors persist, troubleshoot with strace to examine PHP processes. Alternatively, add -d opcache.enable_cli=0 to disable OpCache temporarily in cron jobs:

/path/to/php -q -d opcache.enable_cli=0 public_html/billing/crons/cron.php

Did this answer help?

« Back