Uh, what they said is not accurate at all. You can of course change the OPcache settings on a shared hosting plan since the important configuration variables in question are user-configurable as per PHP's documentation. The configuration target for each of those settings is:
opcache.validate_timestamps: INI_ALL
opcache.revalidate_freq: INI_ALL
opcache.enable_file_override: INI_SYSTEM
opcache.revalidate_path: INI_ALL
The opcache.enable_file_override indeed has a configuration target of INI_SYSTEM (meaning: “Entry can be set in php.ini or httpd.conf”), but the rest have a configuration target of INI_ALL (meaning: “Entry can be set anywhere” i.e. using ini_set() as well as the php.ini, .htaccess, httpd.conf or .user.ini files).
The opcache.enable_file_override setting is just a precaution. It is NOT necessary to run Kickstart IF you have set up opcache.validate_timestamps to 1 (or true) AND opcache.revalidate_freq is set to something sufficiently low (e.g. 1) and opcache.revalidate_path is set to 1 (or true). These can be set up in a .user.ini file. The PHP documentation is slightly vague at this point, but the configuration target meaning is as follows:
| Mode |
php.ini |
httpd.conf / .htaccess |
.user.ini |
ini_set() |
INI_SYSTEM |
✅ |
✅ |
❌ |
❌ |
INI_PERDIR |
✅ |
✅ |
✅ |
❌ |
INI_USER |
✅ |
❌ |
✅ |
✅ |
INI_ALL |
✅ |
✅ |
✅ |
✅ |
Therefore, you need to create a .user.ini or php.ini file in your site's root with the following contents:
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.revalidate_path=1
The only question is, should you create a .user.ini file, or a php.ini file? This depends on how PHP is set up to run on the server. This is the part I do not and cannot know as it's up to the host to configure their server. The .user.ini files are used when PHP runs through PHP-FPM. The php.ini files are used when PHP runs as a CGI script.
If the host has instead chosen to run PHP as an Apache module (terribly insecure and inefficient!) you would need to create a .htaccess file in the parent directory of the web root with the following contents:
php_value opcache.validate_timestamps 1
php_value opcache.revalidate_freq 2
php_value opcache.revalidate_path 1
All your host has to tell you is how they run PHP on their server (PHP-FPM, CGI, or as an Apache module) so we can pick which method to use. Instead of doing that, they lied to you that PHP cannot be configured on a shared host which is simply not the case. Are you sure you spoke to someone who knows what they're doing? I have my doubts. It sounds like you spoke to some first level tech who had no idea what the heck they were talking about at all whatsoever.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!