OPcache "up and running" but doesn't cache any scripts

Jim Ratliff

Member
Jan 1, 2018
18
3
3
Oakland CA
cPanel Access Level
Root Administrator
I installed and enabled OPcache (EasyApache 4, FastCGI, non-shared VPS) using WHM»Software»Easy Apache 4»All PHP Options + OpCache.

My sites run PHP 5.6.33 (ea-php56).

phpinfo() confirms that "Opcode caching" is "Up and Running".

I also monitor OPcache using opcache-gui-2.4.0. It tells me:
  • number of cached files: 1
  • number of hits: 0
  • number of misses: 1
  • number of blacklist misses: 0
Specifically, the 1 cached file (that opcache-gui lists in the "File usage" tab) is the opcache-gui script itself. I.e., it's not caching any of the actual substantive scripts that are executing. (These are a combination of WordPress, MediaWiki, and TikiWIki sites.)

Question: Why is OPcache not caching any of the PHP scripts that are executed?

Here are the lines that I added to php.ini via WHM»MultiPHP INI Editor (targeted at ea-php56):
PHP:
opcache.memory_consumption=64
opcache.interned_strings_buffer=4
opcache.max_accelerated_files=7963
opcache.revalidate_freq=600
opcache.fast_shutdown=0
opcache.enable_cli=1
opcache.enable=1
[Side note: I did not add the following to php.ini:
PHP:
zend_extension=/opt/cpanel/ea-php56/root/usr/lib64/php/modules/opcache.so
even though I thought I was supposed to. (When I did, it crashed the whole site with a 500 Internal Server Error.)]

I'm also attaching a pdf of:
  • phpinfo(), part 1, showing the first page of the output
  • phpinfo(), part 2, showing the OPcache part of the output
  • the "Overview" tab of the output from opcache-gui script.
I'd appreciate hearing ideas of what to do next, what additional information I could provide that might help the diagnosis, etc.

Server Version: Apache/2.4.29 (cPanel) OpenSSL/1.0.2n mod_bwlimited/1.4
Server MPM: worker

Thanks!
Jim
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463

Jim Ratliff

Member
Jan 1, 2018
18
3
3
Oakland CA
cPanel Access Level
Root Administrator
Thanks, Michael! I had not enabled PHP-FPM for any of my accounts.

Taking your implicit suggestion, I enabled PHP-FPM on all of my accounts and OPcache started working like it should (caching thousands of files, using its memory, etc.)

Even with all that I had already read (including three of your links), I had never seen anyone say that PHP-FPM is a prerequisite for OPcache. Is that the case?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Even with all that I had already read (including three of your links), I had never seen anyone say that PHP-FPM is a prerequisite for OPcache. Is that the case?
Hello,

It's not required, but Opcode caching programs are not compatible with the suPHP or CGI PHP handlers. The caching program either does not function, or functions incorrectly when using those handlers. Thus, you'd generally want to use either DSO or PHP-FPM. This is documented at:

PHP Options - EasyApache 4 - cPanel Documentation

Thank you.
 

Jim Ratliff

Member
Jan 1, 2018
18
3
3
Oakland CA
cPanel Access Level
Root Administrator
Thanks, Michael! I see (and had seen before) that "Opcode caching programs are not compatible with the suPHP or CGI PHP handlers. The caching program either does not function, or functions incorrectly." But I thought that Fast-CGI wasn't implicated (as being distinct from vanilla CGI). For example in:
PHP Extension: OPCache - EasyApache - cPanel Documentation
it says:
We strongly recommend that you use the DSO or fcgi PHP handlers if you install OPCache.
And I had thought that "fcgi" was synonymous with Fast-CGI. (Perhaps that was my error. Although if you search for "fcgi" on Wikipedia, it sends you to FastCGI.)

In any case, whatever terminological confusions I might have, you've steered me where I needed to go to get OPcache up and running and actually caching files. My load times are better.

Next step is to tune the parameters, where I've learned I can't reliably use MultiPHP INI Editor to do that. (Except, puzzlingling for the "opcache.revalidate_freq" which does seem to be successfully changed when I use MultiPHP INI Editor.) But your other posts, e.g.,
Enabling PHP-FPM in MultiPHP Manager
will be helpful. I may have questions about that, but that'll be a separate topic.

Feel free to close this thread. Thanks!
 
  • Like
Reactions: cPanelMichael