First of all, you must disable by default opcache for PHP versions <5.6.30 and between 7.0.0 and 7.0.14. This is because of CVE-2015-8994. That security hole is making opcache totally unacceptable for shared hosting servers. Let me quote:
Next I propose an update to the default opcache configuration which comes with DirectAdmin. Currently it is:
Please consider the following additions:
and a change:
Let me explain about the last one - it's pointless to have revalidate_freq higher than 0 when opcache.validate_permission is 1. The validation of permissions will do a disk operation anyway - you are almost not saving anything for not checking the timestamp since they are both in the filetable metadata anyway. On the other side it may have negative effect for users - they upload new version of their script and because of the caching... not seeing the results on the site. It's acceptable when I host all my files but I won't count it such when many users are using the server and almost nobody knows about that side effect of the caching. So briefly - not speeding up and causing confusion at the same time. It's not needed on shared hosting.
Child PHP processes inherit the SHM descriptor, using it to cache and retrieve compiled script bytecode ("opcode" in PHP jargon). Cache keys vary depending on configuration, but filename is a central key component, and compiled opcode can generally be run if a script's filename is known or can be guessed. Many common shared-hosting configurations change EUID in child processes to enforce privilege separation among hosted users (for example using mod_ruid2 for the Apache HTTP Server, or php-fpm user settings). In these scenarios, the default Zend OpCache behavior defeats script file permissions by sharing a single SHM cache among all child PHP processes. PHP scripts often contain sensitive information: Think of CMS configurations where reading or running another user's script usually means gaining privileges to the CMS database.
Next I propose an update to the default opcache configuration which comes with DirectAdmin. Currently it is:
Code:
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
opcache.validate_permission=1
Please consider the following additions:
Code:
opcache.use_cwd=1 > this is the default anyway but "just in case" it must be absolutely always 1 for shared hosting. This causes the keys to be absolute path and not a relative one
opcache.revalidate_path=1 > not a fix but it's a hardening of security when symlinks are used. An issue can occur if user created symlinks and then change them.
opcache.enable_file_override=1 > speeds up loading when functions file_exists(), is_file() and is_readable() are used. It's a performance feature.
and a change:
Code:
opcache.revalidate_freq=0
Let me explain about the last one - it's pointless to have revalidate_freq higher than 0 when opcache.validate_permission is 1. The validation of permissions will do a disk operation anyway - you are almost not saving anything for not checking the timestamp since they are both in the filetable metadata anyway. On the other side it may have negative effect for users - they upload new version of their script and because of the caching... not seeing the results on the site. It's acceptable when I host all my files but I won't count it such when many users are using the server and almost nobody knows about that side effect of the caching. So briefly - not speeding up and causing confusion at the same time. It's not needed on shared hosting.