Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP-FPM Opcache config troubles

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by redbird, Apr 7, 2018.

  1. redbird

    redbird Member

    63
    9
    8
    Aug 28, 2015
    Web
    Ratings:
    +16
    Local Time:
    8:48 AM
    Hi all,

    We have 2 centminmod VPSs both with zend opcache enabled with pretty much the same settings.

    However, one of them caches absolutely all php files and the other one caches only wordpress php files and NOT our custom phps.

    We cannot in the world define where to tweak these setting.

    Where are the settings of opcache that define what php files (directories) to cache and what to skip.

    Thanks.
     
  2. eva2000

    eva2000 Administrator Staff Member

    33,719
    7,466
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,478
    Local Time:
    8:48 AM
    Nginx 1.13.x
    MariaDB 5.5
    Nothing in Centmin Mod out of box default PHP-FPM Zend OpCache configurations would do what you're experience in selectively caching PHP opcode. You can customise your Zend Opcache settings yourself in their own .ini settings file as outlined at centminmod.com/phpfpm.html#customphpini. You might want to create /etc/centminmod/php.d/b_customphp.ini to override centmin mod defaults at /etc/centminmod/php.d/a_customphp.ini and restart PHP-FPM. Also outlined in Getting Started Guide Step 17

    list of all default Centmin Mod .ini settings files via command php --ini
    Code (Text):
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini
    

    Zend Opcache settings are set in /etc/centminmod/php.d/zendopcache.ini. So to override them create a new .ini file that is alphabetically ordered after zendopcache.ini to override any settings in /etc/centminmod/php.d/zendopcache.ini i.e. /etc/centminmod/php.d/zzz-zendopcache.ini
    Code (Text):
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini,
    /etc/centminmod/php.d/zzz-zendopcache.ini
    

    be sure to restart php after making changes
    Code (Text):
    service php-fpm restart
    

    or cmd shortcut
    Code (Text):
    fpmrestart
    

    To check current Zend Opcache settings
    Code (Text):
    php --ri "Zend Opcache"
    

    example output which shows both local and master value (global values which usually are the same)
    Code (Text):
    php --ri "Zend Opcache"
    
    Zend OPcache
    
    Opcode Caching => Disabled
    Optimization => Disabled
    SHM Cache => Enabled
    File Cache => Disabled
    Startup Failed => Opcode Caching is disabled for CLI
    
    Directive => Local Value => Master Value
    opcache.enable => On => On
    opcache.use_cwd => On => On
    opcache.validate_timestamps => On => On
    opcache.validate_permission => Off => Off
    opcache.validate_root => Off => Off
    opcache.inherited_hack => On => On
    opcache.dups_fix => Off => Off
    opcache.revalidate_path => Off => Off
    opcache.log_verbosity_level => 1 => 1
    opcache.memory_consumption => 496 => 496
    opcache.interned_strings_buffer => 16 => 16
    opcache.max_accelerated_files => 65407 => 65407
    opcache.max_wasted_percentage => 5 => 5
    opcache.consistency_checks => 0 => 0
    opcache.force_restart_timeout => 180 => 180
    opcache.revalidate_freq => 180 => 180
    opcache.file_update_protection => 2 => 2
    opcache.preferred_memory_model => no value => no value
    opcache.blacklist_filename => no value => no value
    opcache.max_file_size => 0 => 0
    opcache.protect_memory => 0 => 0
    opcache.save_comments => 1 => 1
    opcache.fast_shutdown => 0 => 0
    opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
    opcache.opt_debug_level => 0 => 0
    opcache.enable_file_override => On => On
    opcache.enable_cli => Off => Off
    opcache.error_log => no value => no value
    opcache.restrict_api => no value => no value
    opcache.lockfile_path => /tmp => /tmp
    opcache.file_cache => no value => no value
    opcache.file_cache_only => 0 => 0
    opcache.file_cache_consistency_checks => 1 => 1
    opcache.huge_code_pages => On => On
    
     
    • Informative Informative x 1
  3. redbird

    redbird Member

    63
    9
    8
    Aug 28, 2015
    Web
    Ratings:
    +16
    Local Time:
    8:48 AM
    Still couldn't find anything in settings that would do that selective caching.

    So what's the proper way to turn off opcache just for a particular vhost and leave it on for the rest of them? Instead of doing it globally.

    Update: actually found just one difference in opchache settings between these two servers:

    opcache.huge_code_pages=1

    Was '0' on the other one.

    So basically we need a way to completely turn off opcache for a particular vhost on that new server as it is a dev / stage site where php cache is not needed.
     
    Last edited: Apr 8, 2018
  4. eva2000

    eva2000 Administrator Staff Member

    33,719
    7,466
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,478
    Local Time:
    8:48 AM
    Nginx 1.13.x
    MariaDB 5.5
    oh i thought you mean zend opcache issue was one site was cached and one wasn't ? or you mean you want to do that have one site cached and one not ? if it's latter then see @nVidian post at PHP-FPM - Enable/Disable Zend Opcache per vhosts
     
    • Winner Winner x 1
  5. redbird

    redbird Member

    63
    9
    8
    Aug 28, 2015
    Web
    Ratings:
    +16
    Local Time:
    8:48 AM
    Always prompt help and to the point. Thanks again George. Do you ever sleep ? ;)
     
    • Like Like x 1
  6. eva2000

    eva2000 Administrator Staff Member

    33,719
    7,466
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,478
    Local Time:
    8:48 AM
    Nginx 1.13.x
    MariaDB 5.5
    Who needs sleep :sleep::LOL:
     
    • Funny Funny x 2
..