How can I enable PHP OPcache?

In the /usr/local/etc/php.ini file, the configuration lines for opcache must be modified or added as follows:

[opcache]
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

Next, restart the php_fpm service:

sudo service php_fpm restart