Are you a website owner on a Linux server with OpCache installed, or using WHMCS as one of WebHostingM resellers? You might need to disable OpCache for various reasons, such as resolving segmentation faults or enabling specific payment gateways. Let's guide you through the steps to do this safely and effectively.
Before proceeding with OpCache configuration:
- Test these steps in your WHMCS dev environment first. Ask us for a dev license if you have purchase your WHMCS license from WebHostingM.
- Backup your current OpCache configuration.
- Check OpCache's official documentation for the most up-to-date instructions.
- Ensure you have selected an appropriate maintenance window.
Understanding OpCache
OpCache is a caching engine built into PHP that improves performance by storing precompiled script bytecode in shared memory. While it speeds up performance, it can sometimes cause issues, particularly if it holds onto outdated or conflicting data, leading to errors like "Segmentation fault" or problems with certain functionalities in WHMCS.
Why Disable OpCache?
Disabling OpCache is crucial when:
- You encounter segmentation faults indicating that PHP is crashing, often due to OpCache problems.
- You need to enable specific features or payment gateways in WHMCS, as OpCache can interfere with these actions.
For WHMCS users, improper OpCache management can lead to persistent errors, disrupting your service. It's essential to ensure OpCache is either configured correctly or disabled if issues arise.
Pre-requisites
- SSH access to your Linux server.
- Root or sudo privileges.
- Basic knowledge of editing configuration files.
Steps to Disable OpCache for WHMCS
- Connect to Your Server
Open your terminal and connect to your server using SSH:
ssh $username@$server-ip
- Edit the PHP Configuration File
Locate your PHP configuration file, typically named php.ini
. Find its location by running:
php --ini
Open the file in a text editor (like nano or vim):
sudo nano /path/to/php.ini
- Disable OpCache
In the php.ini
file, locate the following line:
opcache.enable=1
Change it to:
opcache.enable=0
- Restart Your Web Server
After saving your changes, restart your web server to apply them:
sudo systemctl restart apache2 # For Debian/Ubuntu
sudo systemctl restart httpd # For RedHat/CentOS
sudo /usr/local/cpanel/scripts/restartsrv_apache --restart # For cPanel & WHM
- Verify Changes
To confirm that OpCache is disabled, run:
php -i | grep "opcache.enable"
You should see:
opcache.enable => Off => Off
WHMCS-Specific Troubleshooting Steps
If you're encountering specific issues with WHMCS, follow these additional troubleshooting steps:
- Check for Segmentation Faults
If you see "Segmentation fault" errors, it may be linked to OpCache. To test this, temporarily disable OpCache in the command line using:
/path/to/php -q -d opcache.enable_cli=0 public_html/billing/crons/cron.php
or
/path/to/php -q -d opcache.enable_cli=0 /$user/crons/cron.php
If the error does not occur again, the issue is likely with OpCache.
- Resolve Class Not Found Errors
Errors like:
Fatal error: Uncaught Error: Class "Laminas\ZendFrameworkBridge\Autoloader" not found...
indicate that OpCache is serving stale cache data. To fix this, ensure OpCache is disabled as outlined above and clear any remaining cache.
- Check PHP Error Logs
Inspect your PHP error logs for additional clues and look for any related errors that could guide your troubleshooting efforts.
Additional Troubleshooting
If you're still encountering issues, try the following:
- Check your PHP error logs for any additional errors.
- Investigate your PHP configuration using the
strace
utility:
strace -e trace=file php $script.php
- For persistent errors, consider consulting our support team for additional assistance.
Common Gotchas to Avoid
- Always back up your current
php.ini
file before making changes. - Test changes in a staging environment if possible to avoid downtime.
- Be cautious of other PHP extensions that may conflict with OpCache.
Conclusion
Disabling OpCache can help resolve many issues you might face while using WHMCS on your Linux server. By following these steps, you'll ensure smoother operation for your applications. If you have any questions or need further assistance, don't hesitate to reach out to our support team!