How To Disable OpCache in cPanel & Plesk When Using WHMCS Print

  • OpCache, WHMCS, cPanel, Plesk, PHP, phpinfo
  • 0

Before proceeding with OpCache configuration:

  • Test these steps in a non-production WHMCS environment first
  • Backup your current OpCache configuration
  • Check WHMCS and OPcache official documentation for the most up-to-date instructions
  • Ensure you have selected the appropriate maintenance window
  • If using WHMCS, notify your customers about potential brief downtime

Understanding OpCache and WHMCS

Key Terms:

  • OpCache: PHP's built-in code caching system that improves performance by storing precompiled script bytecode in memory
  • WHMCS: Web Hosting Management & Billing System
  • .user.ini: Per-directory PHP configuration file
  • php.ini: PHP configuration file

Prerequisites

  • SSH access to your server
  • cPanel or Plesk or root or sudo privileges
  • Backup of your current configuration
  • PHP 8.1 or higher (recommended for WHMCS)

How to Remove OpCache from Your cPanel Server Using EasyApache 4

To disable the OpCache PHP extension from your cPanel & WHM server, follow these steps. This process is suitable for VPS and dedicated server administrators.

1. Log into WHM as the Root User

- Access your WHM interface by navigating to https://$hostname|$serverip:2087 in your web browser.
- Enter your root username and password. WHM requires root access to perform changes on server-wide configurations, such as modifying PHP modules.

2. Access EasyApache 4

- In the WHM dashboard, locate the search bar at the top-left.
- Type "EasyApache 4" and select it from the search results. This interface allows you to configure and update Apache and PHP packages.

3. Customize PHP Extensions

- In the EasyApache 4 interface, look for "Currently Installed Packages" and click on "Customize".
- From the customization options on the left, select "PHP Extensions".

4. Search for and Remove OpCache

- In the list of PHP extensions, use the search bar to find "OpCache".
- Once located, uncheck the box next to the OpCache extension to mark it for removal.

5. Review and Apply Changes

- After unchecking OpCache, navigate to the "Review" section in EasyApache.
- Double-check that OpCache is marked for removal and confirm by clicking on "Provision" to apply the changes.

6. Confirm Removal

- After provisioning, verify that OpCache has been removed. You can do this by checking the PHP info for any remaining OpCache entries. If successfully removed, OpCache-related configurations should no longer be listed.

Once completed, OpCache will be removed from your server. Make sure to test your PHP-based sites to confirm they operate as expected after the extension's removal.

 

How To Enable/Disable OpCache for Specific Domains on cPanel

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.

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.

 

How To Enable/Disable OpCache for Specific Domains on Plesk

  1. Access Plesk Control Panel
    • Log in to your Plesk dashboard
    • Ensure you have administrator privileges
  2. Locate Domain Settings
    • Navigate to: Domains > example_domain.com
    • Click on the Dashboard tab
    • Look for the PHP section
  3. Check Current Configuration
    • Verify PHP version being used
    • Confirm OpCache settings:
      • Look for opcache.enable setting
      • Check disable_functions list
  4. Modify OpCache Settings
    • To enable: Set opcache.enable to "on"
    • To disable: Set opcache.enable to "off"
  5. Global PHP Settings Check
    • Navigate to: Tools & Settings > PHP Settings
    • Select your PHP version handler
    • Verify OpCache settings at global level

Monitoring OpCache Performance

To check OpCache statistics:

  1. Go to Domains > example_domain.com
  2. Click PHP Settings
  3. Select "View the php_info() page"
  4. Look for:
    • Cache hits
    • Cache misses
    • Memory usage
    • Cache status

Common Plesk-Specific Issues

  • Function Access Denied: Check if opcache_get_status is in the disable_functions list
  • Settings Not Applied: Ensure changes are saved at both domain and global levels
  • Performance Issues: Monitor cache hit/miss ratios through php_info() page

Using php.ini (For Vanilla VPS/Dedicated Servers)

  1. Locate your php.ini:
    php -i | grep "Loaded Configuration File"
  2. Backup php.ini:
    sudo cp /etc/php/8.2/apache2/php.ini /etc/php/8.2/apache2/php.ini.backup
  3. Edit php.ini:
    sudo vim /etc/php/8.2/apache2/php.ini
  4. Find and modify these settings:
    opcache.enable=0
    opcache.enable_cli=0
  5. Restart Apache:
    # For Debian/Ubuntu
    sudo systemctl restart apache2
    
    # For RedHat/CentOS
    sudo systemctl restart httpd
    
    
    

Common Issues and Solutions in Vanilla VPS/Dedicated Servers

  • Changes Not Taking Effect:
    # Clear OpCache manually
    sudo php -r 'opcache_reset();'
    
    # Restart PHP-FPM if used
    sudo systemctl restart php8.2-fpm
  • Permission Issues:
    # Check file permissions
    ls -la .user.ini
    sudo chown www-data:www-data .user.ini
    sudo chmod 644 .user.ini

Restoring OpCache in Vanilla VPS/Dedicated Servers

To re-enable OpCache, simply reverse the changes made above or restore from your backup:

sudo cp /etc/php/8.2/apache2/php.ini.backup /etc/php/8.2/apache2/php.ini
sudo systemctl restart apache2

Verifying OpCache is Disabled

  1. Create a PHP info file (remove after testing):
    echo "" > opcache-test.php
  2. Check via browser: example_domain.com/opcache-test.php
  3. Search for "opcache" and verify it's disabled
  4. Remove the test file:
    rm opcache-test.php

When running on CloudLinux environments, you may encounter specific issues that require special handling.

Blank Pages or 503 Errors with OpCache

Add this parameter to opcache.ini:

opcache.optimization_level=0

Note: This disables optimization but maintains caching, useful when the OpCache optimizer causes PHP crashes.

PHP Selector Issues

Diagnostic Command:

/opt/alt/php82/usr/bin/php-cgi -d opcache.enable_cli=0 -d zlib.output_compression=Off -d auto_append_file=none -d extension=mbstring.so -d auto_prepend_file=none -d disable_functions=none -qi

Solution:

Update your system:

sudo yum update

IonCube Loader Conflicts

Symptoms:

  • 503 errors
  • LSAPI errors in logs
  • Issues with IonCube + OpCache JIT

Error Log Example:

[lsapi:error] [pid 6246:tid 23402262411008] [client 203.0.113.2:0] [host example.com] Error on sending request(GET / HTTP/1.1); uri(/) content-length(0): ReceiveAckHdr: nothing to read from backend (LVE ID 1031)

Solution:

  1. Update alt-PHP packages:
    sudo yum groupupdate alt-php81* alt-php82*
  2. Important: JIT should remain disabled when using IonCube + OpCache on alt-PHP 8.x

⚠️ Important: On CloudLinux servers, using JIT with OpCache + alt-PHP8x + IonCube is not recommended as it can cause 503 errors. This combination is disabled by default for stability reasons.

Best Practices

  • Monitor server performance after disabling OpCache
  • Consider using development environments for testing
  • Document any configuration changes
  • Set up monitoring for PHP memory usage
  • Plan to re-enable OpCache after debugging

Performance Monitoring

After disabling OpCache, monitor these metrics:

  • PHP memory usage
  • Page load times
  • Server CPU usage
  • WHMCS response times

Did this answer help?

« Back

Trusted by over 35,000 customers in over 200 countries