Speed is the lifeline of a website; being even a fraction of a second slow can cause users to leave.
On HestiaCP In this environment, PHP's OPcache is a key weapon for improving performance. It allows your code to be like an engine that has been "preheated" and is ready to go at any time, reducing duplicate parsing and lowering CPU load.
What is OPcache?
OPcache is a bytecode caching extension provided by the official PHP documentation.
Its purpose is to store the compiled PHP script in memory, avoiding recompilation for each request.
The result is faster response times and less server load.
According to the official PHP documentation, enabling OPcache can improve the execution speed of PHP scripts by more than 3 times.

Confirm whether OPcache is enabled.
In HestiaCP, PHP-FPM has OPcache enabled by default, but we can't just guess.
Run the following command:
php -i | grep opcache.enable
If the output is:
opcache.enable => On
This indicates that OPcache is already running.
Another way is to create phpinfo() View the status of OPcache on the page in your browser.
This verification method is intuitive and reliable, and can clearly show memory usage and the number of cached files.
Edit PHP configuration files
Sometimes OPcache doesn't run exactly according to optimal parameters.
At this point, we need to manually modify the configuration file:
sudo nano /etc/php/<版本>/fpm/php.ini
turn up [opcache] To ensure the following parameters are present:
opcache.enable=1
opcache.enable_cli=1
among them opcache.enable_cli=1 It is an optional feature, suitable for scenarios where PHP scripts need to be run from the command line.
Optimize OPcache parameters
Simply enabling it is not enough; proper parameter configuration is necessary to maximize performance.
Memory allocation
opcache.memory_consumption=128
This means allocating 128MB of memory to the cache.
If your website is large, you can increase it to 256MB or 512MB.
Number of cached files
opcache.max_accelerated_files=10000
This parameter determines the maximum number of PHP files that can be cached.
For a medium-sized website, 10000 is a reasonable number.
Timestamp verification
opcache.validate_timestamps=0
Disabling real-time detection reduces file system I/O and improves performance.
However, this means that you must manually clear the cache after modifying PHP files.
Other recommended parameters
opcache.interned_strings_buffer=16
opcache.revalidate_freq=60
opcache.save_comments=1
opcache.fast_shutdown=1
opcache.enable_file_override=1
These parameters can further optimize memory usage and script execution efficiency.
Restart the PHP-FPM service
You must restart the service for the changes to take effect.
sudo systemctl restart php<版本>-fpm
run again phpinfo() Or php -i | grep opcache To confirm whether the parameters have been updated.
Best practices in production environments
In a production environment, OPcache configuration needs to balance performance and stability.
- Disable real-time detection :
opcache.validate_timestamps=0This reduces performance loss. - CI/CD deployment scripts clear cacheExecute during code updates
opcache_reset()Or restart PHP-FPM. - Monitor cache status:use
opcache_get_status()Check memory usage and cache hit rate.
For example, a certainE-commerceAfter enabling OPcache, the website's page load time decreased from 1.2 seconds to 0.4 seconds, and CPU usage dropped by 35%.
Authoritative viewpoints cited
According to Zend's official performance tests, enabling OPcache can increase the throughput of PHP applications by up to [percentage missing]. 200%The latency was reduced by more than 50%.
This is not theory, but data based on large-scale field measurements.
Conclusion: My Viewpoint
OPcache acts like a "speed engine" for your website, allowing your PHP code to run efficiently instead of doing repetitive tasks.
Enabling and optimizing OPcache in HestiaCP can not only improve speed, but also maximize the utilization of server resources.
In this age of information overload, speed is the key to competitiveness.
As Nietzsche said, "Thoughts without speed are empty echoes."
So don't let your server languish in inefficiency; enable OPcache now and make your website fly.
Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ The article "HestiaCP PHP Accelerator OPcache: A Complete Guide to Installation and Activation" shared here may be helpful to you.
Welcome to share the link of this article:https://www.chenweiliang.com/cwl-34158.html
