Overview
This guide will show you how to configure and optimize PHP Opcache settings.
Opcache significantly enhances the performance of PHP-based applications by storing precompiled script bytecode in the server's shared memory. By utilizing a dedicated opcache.ini file, you can maintain a modular configuration that remains unaffected by global system updates.
php56, php70, php71, php72, php73, php74, php80, php81, php82, php83,php84,php85
Steps:
Create a new opcache.ini file at /usr/local/apps/php81/etc/php.d/
You can create and edit this file using the following command:
nano /usr/local/apps/php81/etc/php.d/opcache.iniInside the file, add the PHP directives you wish to modify. For example:
; Enable Opcache
opcache.enable=1
opcache.enable_cli=1
; Memory Management
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
; Validation Settings
opcache.revalidate_freq=2
opcache.validate_timestamps=1Once you have saved the file, you must restart the PHP-FPM service for the changes to take effect.
Execute the following command:
/usr/local/apps/php81/bin/fpmctl restartYou can verify that your settings have been applied correctly by running the following command in your terminal:
/usr/local/apps/php81/bin/php -i | grep opcacheThat's it! Your custom PHP settings are now loaded for PHP 8.1 ,similarly you can load in other PHP's, just replace the php softname which is already mentioned above.