How to Edit Opcache Settings for DirectAdmin
You may find that you need to increase the opcache.memory_consumption or some other setting for Opcache. To do so, you will need to create a custom configuration file with the settings you’d like to build Opcache with that DirectAdmin’s CustomBuild will recognize. Then, copy the original opcache.ini file over to this custom/ directory.
cd /usr/local/directadmin/custombuild mkdir -p custom/opcache cp -p configure/opcache/opcache.ini custom/opcache/opcache.ini
Now, edit the custom/opcache.ini with your desired changes.
nano custom/opcache/opcache.ini ./build opcache
Opcache should now be configured with the settings desired and these changes will survive subsequent CustomBuild builds.
Fine-tune your Opcache configuration
opcache.memory_consumption=512 # MB, adjust to your needs opcache.interned_strings_buffer=64 opcache.max_accelerated_files=50000 # Adjust to your needs opcache.max_wasted_percentage=10 # Adjust to your needs opcache.validate_timestamps=0 opcache.revalidate_freq=0 opcache.enable_cli=1 opcache.use_cwd=1 opcache.revalidate_path=1 opcache.enable_file_override=1 opcache.fast_shutdown=1
(enabled by default “1”)If enabled, OPcache will check for updated scripts every opcache.revalidate_freq=# of seconds. When disabled, opcache.revalidate_freq is ignored, and you must reset OPcache manually via opcache_reset(), opcache_invalidate(), or by restarting PHP for changes to the filesystem to take effect.
So by default, OPcache tries to be as developer-friendly as possible with timestamps to validate cached files. However, this convenience comes at the cost of performance as it does add operational memory overhead. For many production servers, especially when you have a separate development server, this directive can be safely disabled.
If you need to keep it enabled, increase the time between checks from 2 seconds to maybe 10 or more, depending on what you can live with.