Yukinarija

Member
Nov 2, 2016
18
1
3
Lithuania
cPanel Access Level
Root Administrator
Hey,

Installed OpCache for 5.6 and 7.0. By default it works fine in 7.0, in 5.6 it seems to always 'miss' on at least one of my projects.

Where's the config for opcache stored though? php.ini doesn't have anything representative, and adding some config like this:

opcache.enable=1
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


at the end - doesn't change the default values. Is there any default opcache config somewhere for 5.6 and 7.0 separately? I will start searching the system for string matches.

Cheers.
 

roliboli

Well-Known Member
Sep 3, 2003
48
2
158
Switzerland
Hi
the settings are per modul and PHP version specific:
/opt/cpanel/ea-php56/root/etc/php.d/10-opcache.ini
/opt/cpanel/ea-php70/root/etc/php.d/10-opcache.ini

But my problem is that OpCache is not working. I have the recommende configuration with php-mpm prefork. But the documentations says that the all cgi-handlers are not compatible with OpCache (PHP Options - EasyApache 4 - cPanel Documentation "Opcode caching programs are not compatible with the suPHP or CGI PHP handlers. The caching program either does not function, or functions incorrectly.")

So after provisioning with extension OpCache the module is enabled. But there are only misses. Do you have the same problem?

Regards
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
Hello,

The "Warnings" section under the Opcache section on the following document explains some key considerations:

PHP Options - EasyApache 4 - cPanel Documentation

It notes:

  • EasyApache 4 does not currently support any opcode cacher other than OPCache.
  • Opcode caching programs are not compatible with the suPHP or CGI PHP handlers. The caching program either does not function, or functions incorrectly.
  • The system does not automatically configure OPCache. If you do not manually configure OPCache after you install it, it will provide no benefits.
  • We strongly recommend the DSO PHP handler for the OPCache opcode cacher.
  • Do not install multiple PHP caching programs on the same system. Multiple opcode caching programs consume excessive memory and degrade system performance.
Also, regarding the php.ini changes, ensure they are added to the following file for PHP 5.6:

Code:
/opt/cpanel/ea-php56/root/etc/php.d/opcache.ini
Thank you.
 

Yukinarija

Member
Nov 2, 2016
18
1
3
Lithuania
cPanel Access Level
Root Administrator
Hi
the settings are per modul and PHP version specific:
/opt/cpanel/ea-php56/root/etc/php.d/10-opcache.ini
/opt/cpanel/ea-php70/root/etc/php.d/10-opcache.ini

But my problem is that OpCache is not working. I have the recommende configuration with php-mpm prefork. But the documentations says that the all cgi-handlers are not compatible with OpCache (PHP Options - EasyApache 4 - cPanel Documentation "Opcode caching programs are not compatible with the suPHP or CGI PHP handlers. The caching program either does not function, or functions incorrectly.")

So after provisioning with extension OpCache the module is enabled. But there are only misses. Do you have the same problem?

Regards
Hey roliboli, yep - same issue. But somehow with 7.0 and CGI it starts hitting - strange. I hope that it works with fCGI as well as with DSO PHP. For our needs we could even use DSO, so it's pretty okay.


Hello,

The "Warnings" section under the Opcache section on the following document explains some key considerations:

PHP Options - EasyApache 4 - cPanel Documentation

It notes:



Also, regarding the php.ini changes, ensure they are added to the following file for PHP 5.6:

Code:
/opt/cpanel/ea-php56/root/etc/php.d/opcache.ini
Thank you.
Thanks Michael.
 

roliboli

Well-Known Member
Sep 3, 2003
48
2
158
Switzerland
Hi Michael

So there is no possibility to have OpCache with php-fpm (prefork)? It makes no sense to activate OpCache because the apachebench shows slower values instead more speed. Both php7 and php56. Actually we have on another server EA3 with fcgid and OpCache which is much faster than the php-fpm.

DSO is not possible for me because I need the process running under user rights.

Regards
 

Yukinarija

Member
Nov 2, 2016
18
1
3
Lithuania
cPanel Access Level
Root Administrator
Hey roli,

They replied to me in an another thread saying that fCGI is not available until version 62 IIRC. Only DSO+OpCache is possible in EA4.
Overall, as much as I like PHP7, if you can't use DSO (like I can't in one of our servers), need to revert back to EA3 then until 62 and fCGI.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
So there is no possibility to have OpCache with php-fpm (prefork)? It makes no sense to activate OpCache because the apachebench shows slower values instead more speed. Both php7 and php56. Actually we have on another server EA3 with fcgid and OpCache which is much faster than the php-fpm.
Hello,

It's possible to use OPCache with PHP-FPM, yes.

Regarding FastCGI, PHP-FPM is similar to FastCGI, but there are differences to how they are configured to work (e.g. PHP-FPM uses mod_proxy_fcgi as it's backend). Support for mod_fcgid in cPanel version 62 provides the same FastCGI handler that was offered in EasyApache 3. This is discussed under the comments section at:

EasyApache 4 mod_fcgid

Thank you.
 

roliboli

Well-Known Member
Sep 3, 2003
48
2
158
Switzerland
Hi Michael

It's possible to use OPCache with PHP-FPM, yes.
But in the documentation is writtten: "Opcode caching programs are not compatible with the suPHP or CGI PHP handlers". So in my point of view PHP-FPM is meant for "CGI PHP handlers".

I installed mainly mod_mpm_prefork, mod_ruid2, php-fpm (EA4: Cpanel Default). Then OpCache can be enabled but it producess always misses and the performance is slower than without OpCache.

Regards
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
Hello @roliboli,

Could you elaborate a little more on your last response? Are you suggesting we update the PHP Options document to include support for PHP-FPM and Opcache?

Thank you.
 

roliboli

Well-Known Member
Sep 3, 2003
48
2
158
Switzerland
I don't now if the documentation is correct. Because you say that PHP-FPM is working with OpCache. But with mod_mpm_prefork, mod_ruid2, php-fpm (default config) OpCache doesn't work correct (in my opinion). I think PHP-FPM uses the CGI Handler.

All I want to have is a PHP-FPM configuration (not DSO) with working OpCache for better performance.

Best regards
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
But with mod_mpm_prefork, mod_ruid2, php-fpm (default config) OpCache doesn't work correct
Could you test with Mod_Ruid2 disabled and see if you notice similar results? Here's some alternatives for symlink protection if you need to disable Mod_Ruid2:

EasyApache4 symlink race protection

Thank you.
 

roliboli

Well-Known Member
Sep 3, 2003
48
2
158
Switzerland
I disabled Mod_Ruid2 and there are only misses in both PHP7 and PHP56. Do you have a EA4 configuration with working OpCache? But I need CGI because the process should be executed under the user.

Regards
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
Hello @roliboli,

Could you open a support ticket using the link in my signature so we can review your system's specific configuration and verify why OPcache isn't working?

Thank you.
 

Yukinarija

Member
Nov 2, 2016
18
1
3
Lithuania
cPanel Access Level
Root Administrator
Hey guys,

Turns out I did not read the replies right, so if somebody was also confused -> OPCache config in EA4


I am now using PHP 7.0 with PHP-FPM, in the GUI 'CGI' is selected, phpinfo shows:

FPM/FastCGI


And Zend OpCache is actually working and being hit. File for config is available here: /opt/cpanel/ea-php70/root/etc/php.d/10-zend.ini

So yeah, OpCache works like this. And PHP-FPM uses the mod_fcgid, rather than straight FCGID, but I am not sure how much worse that is? I'd love to compare when we get a proper FCGID. Maybe somebody could inform me? I am happy that I came back to check, I can now increase Zend limits.