Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Best Practice to enable/configure OPCache w/ EA4:PHP7+PHP-FPM

Discussion in 'EasyApache' started by MaxFein, Dec 10, 2016.

  1. MaxFein

    MaxFein Member

    Joined:
    Jul 29, 2015
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Portland, Oregon, USA, Earth
    cPanel Access Level:
    Root Administrator
    cPanel 60 with EasyApache4

    php7 + php-fpm + OPCache

    I see /opt/cpanel/ea-php70/root/etc/php.d/10-opcache.ini has directives to in place enable and configure OPCache, and phpinfo page shows that the file was parsed in scan for additional .ini files yet OPCache is not showing up as enabled...?

    I did get OPCache working at one point - had just reinstalled the module and it seemed to just start working - however, at that point I was unable to change the settings (eg. opcache.fast_shutdown=1) at all despite apache restarts after every attempt (tried /opt/cpanel/ea-php70/root/etc/php.d/10-opcache.ini /opt/cpanel/ea-php70/root/etc/php.d/local.ini /opt/cpanel/ea-php70/root/etc/php.ini and even /usr/local/lib/php.ini). I tried editing the files manually and also tried the MultiPHP INI Editor.

    Since then I managed to break things somehow while trying to get a config change to happen and OPCache is no longer working... will likely need to reinstall stuff.

    I have a well-known managed hosting provider for this server yet, so far, they seem to be having a hard time answering the Qs below in a way that works... I'm starting to wonder if something is not functioning properly.

    So, the Qs are (EA4 w/ PHP7):

    1) best practice how/where to enable OPCache once installed?

    2) best practice how/where to change/add settings (eg. opcache.memory_consumption=) once enabled?
     
    #1 MaxFein, Dec 10, 2016
    Last edited: Dec 10, 2016
  2. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    907
    Likes Received:
    13
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    From a consol as root check if opcache is installed:
    Code:
    php -v
    If it is then in /opt/cpanel/ea-php70/root/etc/php.d/10-opcache.in check if its enabled:
    Code:
    ; Determines if Zend OPCache is enabled
    opcache.enable=1
    Make sure any comment ( ; ) in front of opcache.enable=1 is removed.
    If php -v shows opcache not installed then run EA4 again
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Please also review the following thread for information on how to edit the PHP configuration values for a domain name when PHP-FPM is enabled on the account:

    Enabling PHP-FPM in MultiPHP Manager

    Thank you.
     
  4. philsward

    philsward Member

    Joined:
    Jan 3, 2017
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    USA
    cPanel Access Level:
    Website Owner
    Same problem as OP

    opcache is working fine, however I can not figure out where the "global" settings are being set from. I've looked in all of the locations where the loaded .ini files reside but I am unable to find where the top level setting is coming from. The ini editor "should" supercede anything before it, so... what comes after other than the user folder which doesn't even have a .ini (.user.ini nor php.ini)?

    I need to change the memory from 96 to a higher number (need to figure out the higher number now that FPM is available to make opcache work) but I can't figure out where to set it. PHP editor should work, but it isn't, regardless of opcache.memory_consumption or zend_optimizerplus.memory_consumption being set to a number different than 96.

    Just short of disabling Zendguard and re-enabling it, I'm not sure where else to go or what to do. I'll keep digging, but I'm pretty confused at this point.
     
  5. philsward

    philsward Member

    Joined:
    Jan 3, 2017
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    USA
    cPanel Access Level:
    Website Owner
    Definitely a bug that needs addressed.

    The ONLY way to make changes is first through the PHP MulitINI Editor, then you MUST go over to PHP Manager, tick off the appropriate PHP version for the domain and hit apply, REGARDLESS of whether or not it is already set.

    Did not test against inherited domains since my lowest PHP version is 5.4 and opcache setup is different for 5.4.

    So, in order to make changes, you have to apply the PHP version through PHP Manager after setting it in the INI editor. Making a change and "saving", will not reflect in phpinfo. Restarting the httpd after saving, will not reflect in phpinfo. After saving and then re-applying the PHP version for a set of domains, WILL reflect in phpinfo.

    Tested against completely removing PHP55, then installing it and moving my PHP56 domain to instead use PHP55. This move reflected the 55 ini opcache settings.

    It was only after moving my 56 domain over to 55 for testing, then back to 56 that I was able to observe the 56 ini settings were now in effect. I then went into the editor, made a few more changes, saved and it did not reflect. Only after re-visiting the manager and re-applying 56 for the domain, did the new changes reflect for the 56 ini.

    All of this said, it is assumed you are using PHP-FPM and it is "ON".
     
    #5 philsward, Jan 3, 2017
    Last edited: Jan 3, 2017
  6. MaxFein

    MaxFein Member

    Joined:
    Jul 29, 2015
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Portland, Oregon, USA, Earth
    cPanel Access Level:
    Root Administrator
    ...so, the changes should be made in /opt/cpanel/ea-php70/root/etc/php.d/10-opcache.ini

    then
    Code:
    systemctl restart ea-php70-php-fpm.service
    systemctl restart httpd
    the bit I was missing was restarting php-fpm, hope that helps ;)
     
  7. philsward

    philsward Member

    Joined:
    Jan 3, 2017
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    USA
    cPanel Access Level:
    Website Owner
    Since I haven't messed with 7 yet, I don't know about the 10-opcache.ini vs php.ini for the settings (which place is better)

    But, @MaxFein, what you're saying is that php-fpm must be restarted as well, which means it isn't getting restarted anytime the phpini editor is edited. (for 55 and 56).

    This is probably going to frustrate a handful of people.

    IMO, whatever triggers a restart of httpd after saving the PHP INI editor, also needs to check for and restart the appropriate php-fpm service as well.
     
  8. ItsMattSon

    ItsMattSon Well-Known Member

    Joined:
    Sep 5, 2016
    Messages:
    140
    Likes Received:
    29
    Trophy Points:
    28
    Location:
    Perth
    cPanel Access Level:
    Root Administrator
    I can confirm that this bug affected me also (for domains that are explicitly set to use PHP-FPM) whereby always_populate_raw_post_data was apparently set to 0, despite it being uncommented and set to -1 in MultiPHP INI Editor.

    Had to re-apply the PHP Version, despite it already having ea-php56 set. Once re-applied, phpinfo showed always_populate_raw_post_data set as -1, as per how I set it in the MultiPHP INI Editor.

    Is this a bug? (Sure seems to be)
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    The issue with changes made via the MultiPHP INI Editor when PHP-FPM is enabled is discussed on the following thread:

    EA4, php.ini editor while using FPM

    Thank you.
     
    ItsMattSon likes this.
Loading...

Share This Page