Discover Centmin Mod today
Register Now

Nginx PHP-FPM After PHP File Update PHP FPM Requires Restart :-(

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Varun, Apr 9, 2018.

  1. Varun

    Varun Premium Member Premium Member

    36
    2
    8
    Apr 6, 2018
    India, Tamil Nadu, Chennai
    Ratings:
    +3
    Local Time:
    9:19 AM
    1.13.11
    Problem :
    I have a added a vhost using centmin menu 2
    and i have created a php file which i used to upload images to the server.
    so when i update then php i need to restart the php fpm Too. i have no idea why the php file requires restart of php fmp


    Nginx Config :
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name iupload.svarun.in;
    #            return 301 $scheme://www.iupload.svarun.in$request_uri;
    #       }
    
    server {
    
      server_name iupload.svarun.in www.iupload.svarun.in;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/iupload.svarun.in/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/iupload.svarun.in/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/iupload.svarun.in/autoprotect-iupload.svarun.in.conf;
      root /home/nginx/domains/iupload.svarun.in/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      location / {
     include /usr/local/nginx/conf/503include-only.conf;
    rewrite /(.*)$ /index.php?view=$1;
    #rewrite /(.*).gif$ /index.php?view=$1;
    #rewrite /(.*).png$ /index.php?view=$1;
    #rewrite /(.*).jpg$ /index.php?view=$1;
    #rewrite /(.*).jpge$ /index.php?view=$1;
    
    
    
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Wordpress Permalinks example
      #try_files $uri $uri/ /index.php?q=$uri&$args;
      }
    
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
    
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    
    
    


    Code Used To Restart After Edit :

    Code:
    [root@charlesbabbage public]# ngxrestart
    Restarting nginx (via systemctl):                          [  OK  ]
    [root@charlesbabbage public]# service php-fpm restart
    Gracefully shutting down php-fpm . done
    Starting php-fpm  done
    



    Please fill in any relevant information that applies to you:
    • CentOS Version: CentOS 7 64bit ?
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: i.e. 1.13.11
    • PHP Version Installed: i.e. 5.6.30 or 7.0.15
    • MariaDB MySQL Version Installed: Unable to find. but its the default when installed the beta version.
    • When was last time updated Centmin Mod code base ? : Its fresh install
    • Persistent Config: I dont have.
      cat /etc/centminmod/custom_config.inc


      Post output in CODE tags.
     
  2. eva2000

    eva2000 Administrator Staff Member

    33,688
    7,459
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,470
    Local Time:
    1:49 PM
    Nginx 1.13.x
    MariaDB 5.5
    It's due to the default revalidate frequency set for 180 seconds
    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.inherited_hack => On => On
    opcache.dups_fix => Off => Off
    opcache.revalidate_path => Off => Off
    opcache.log_verbosity_level => 1 => 1
    opcache.memory_consumption => 64 => 64
    opcache.interned_strings_buffer => 8 => 8
    opcache.max_accelerated_files => 8000 => 8000
    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 => 1 => 1
    opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
    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 => Off => Off


    You can exclude a file or path from Zend Opcache caching completely via blacklist option too
    To customise Zend Opcache settings see the instructions to create your own .ini settings file to retain the changes at https://centminmod.com/phpfpm.html#customphpini

    Example order of php .ini files applied via php --ini command
    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

    If i want to override opcache.revalidate_freq 180 seconds default, I'd create a .ini file after /etc/centminmod/php.d/zendopcache.ini alphabetically i.e. /etc/centminmod/php.d/zzendopcache.ini

    So ordered after 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/zzendopcache.ini


    In /etc/centminmod/php.d/zzendopcache.ini add value say 10 seconds
    Code (Text):
    opcache.revalidate_freq = 10


    Note though reducing revalidation frequency lowers performance of caching all the time 24/7. Best way is just to restart php-fpm and nginx after file updates which are done manually via command shortcut
    Code (Text):
    nprestart

    After restart recheck value is now at 10 seconds
    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.inherited_hack => On => On
    opcache.dups_fix => Off => Off
    opcache.revalidate_path => Off => Off
    opcache.log_verbosity_level => 1 => 1
    opcache.memory_consumption => 64 => 64
    opcache.interned_strings_buffer => 8 => 8
    opcache.max_accelerated_files => 8000 => 8000
    opcache.max_wasted_percentage => 5 => 5
    opcache.consistency_checks => 0 => 0
    opcache.force_restart_timeout => 180 => 180
    opcache.revalidate_freq => 10 => 10
    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 => 1 => 1
    opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
    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 => Off => Off

    Any php related setting can override and customised this way as well :)
     
    • Like Like x 1
    • Informative Informative x 1
..