PHP Opcache setup notes for Drupal 9

Submitted by slackstone on Fri, 12/10/2021 - 05:59


This warning can occur during the Drupal setup when PHP OpCache is not found:
"PHP OPCODE CACHING Not enabled
PHP OPcode caching can improve your site's performance considerably. It is highly recommended to have OPcache installed on your server. "

A resolution is to install the right packages, then setup a new PHP ini file.
( /etc/php.d/10-opcache.ini)

For RHEL 8, install using:
> sudo dnf install  php-zip php-opcache


$ cat /etc/php.d/10-opcache.ini
; Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=4000
; If enabled, a fast shutdown sequence is used for the accelerated code
opcache.fast_shutdown=1
;following can be commented for production server
#opcache.revalidate_freq=0
#opcache.consistency_checks=1

Use a "php phpinfo()" statement somewhere to confirm your PHP Server settings. We keep a basic  "info.php" file within our phpmyadmin area.

https://access.redhat.com/errata/RHSA-2021:4213