Learn about Centmin Mod LEMP Stack today
Become a Member

Wordpress WordPress updates cause error 500 until PHP-FPM restart

Discussion in 'Blogs & CMS usage' started by Daniel J. Lewis, Sep 30, 2016.

  1. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    I have two different VPSs with Vultr. Both are running latest Centminmod with PHP 7.0.11.

    This problem has happened for a while. When I update WordPress or a plugin, every site on my server becomes inaccessible and I receive error 500.

    The only thing that fixes this is restarting PHP-FPM.

    My permissions and ownership are set properly. Resetting them doesn't make the error 500 go away.

    I check the site error logs and the FPM error logs, but there's nothing related to the crash.

    My CPU, RAM, and storage aren't maxed out.

    Simply restarting FPM fixes things. But I'm concerned about the reliability of that, because if stuff is crashing, it's possible that upgrade processes aren't completing.


    Any ideas?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod stable and betas still get updates, and fixes over time after install, so it's important that centmin.sh menu option 23 submenu option 2 is ran. Centmin Mod 123.09beta01 even now alerts you to updates when you log into SSH :) Probably first thing I'd do.

    How was wordpress installed ? via centmin.sh menu option 22 ? which version of centmin mod used at the time 123.08stable or 123.09beta01 ? Might need to see your wordpress site's vhost config files' contents.

    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)

    Upgrading Centmin Mod Code to Latest Version



    Getting Started Guide step 19 outlines also how to keep Centmin Mod code updated or how to switch version branches.

    Centmin Mod LEMP stack's script code is constantly updated for improvements, bug fixes and security fixes so keeping the Centmin Mod code up to date is important. With Centmin Mod 1.2.3-eva2000.08) (123.08stable) and higher releases, a newly added centmin.sh menu option 23 allows much easier code updates and version branch swicthing via Git backed environment you can setup. For full details read the following links:
     
  3. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    Yes, I forgot to mention that I keep Centminmod updated, too. I update it before each time that I update anything else.

    The WordPress were installed either manually or through the Centminmod menu.

    Centminmod was originally installed with 123.07, I think. But some of these sites have been with 123.08stable.

    Here's the nginx conf for one of the sites:

    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 podcasterssociety.com www.podcasterssociety.com;
        # return 301 $scheme://www.podcasterssociety.com$request_uri;
        return 301 https://$server_name$request_uri;
    
      }
    
    server {
        server_name podcasterssociety.com www.podcasterssociety.com;
    
        # 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;
    
        # limit_conn limit_per_ip 16;
        # ssi on;
    
        access_log /home/nginx/domains/podcasterssociety.com/log/access.log combined buffer=256k flush=60s;
        error_log /home/nginx/domains/podcasterssociety.com/log/error.log;
    
        root /home/nginx/domains/podcasterssociety.com/public;
    
    
        # SSL
        # force https-redirects
        # if ($scheme = http) {
        # }
        listen 443 ssl http2;
        ssl on;
        ssl_certificate /usr/local/nginx/conf/ssl/theaudacitytopodcast.com.crt;
        ssl_certificate_key /usr/local/nginx/conf/ssl/theaudacitytopodcast.com.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #    ssl_prefer_server_ciphers on;
    #    ssl_ecdh_curve  secp384r1;
    #    ssl_session_cache      shared:SSL:10m;
    #    ssl_session_timeout  10m;
    #    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
    #    add_header Strict-Transport-Security "max-age=0; includeSubdomains";
        # /SSL
    
          # prevent access to ./directories and files
        location ~ (?:^|/)\. {
            deny all;
        }
    
        # include /usr/local/nginx/conf/wpsupercache_podcasterssociety.com.conf;
    
        # location / {
        # # Enables directory listings when index file not found
        # #autoindex on;
        #
        #     try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
        #
        # }
    
        location / {
    
          if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
          }
    
          if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
          }
    
          if (!-f $request_filename){
            rewrite (.*) /index.php;
          }
    
          # block common exploits, sql injections etc
          include /usr/local/nginx/conf/block.conf;
        }
    
    
    #    location ~* /(wp-login\.php) {
    #        limit_req zone=xwplogin burst=1 nodelay;
    #        #limit_conn xwpconlimit 30;
    #    #    auth_basic "Private";
    #    #    auth_basic_user_file /home/nginx/domains/podcasterssociety.com/htpasswd_wplogin;
    #        include /usr/local/nginx/conf/php-wpsc.conf;
    #    }
    
    #    location ~* /(xmlrpc\.php) {
    #        limit_req zone=xwplogin burst=2 nodelay;
    #        #limit_conn xwpconlimit 30;
    #        include /usr/local/nginx/conf/php-wpsc.conf;
    #    }
    
        include /usr/local/nginx/conf/rocket-nginx/rocket-nginx.conf;
        # include /usr/local/nginx/conf/wpsecure_podcasterssociety.com.conf;
     include /usr/local/nginx/conf/wpsecure.conf;
    #    include /usr/local/nginx/conf/php-wpsc.conf;
        include /usr/local/nginx/conf/php.conf;
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/drop.conf;
        #include /usr/local/nginx/conf/errorpage.conf;
    }
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    If you used centmin.sh menu option 22 to install wordpress, can you post output of these commands in BBCODE CODE tags - How to use forum BBCODE code tags :)

    change vhostname variable to your domain name and /home/nginx/domains/${vhostname}/public to where wordpress is instaleld so /home/nginx/domains/${vhostname}/public for web root or if /blog then /home/nginx/domains/${vhostname}/public/blog
    Code (Text):
    vhostname=yourdomain.com
    cd /home/nginx/domains/${vhostname}/public
    /usr/bin/wp --info --allow-root
    /usr/bin/wp plugin status --allow-root
    

    centmin.sh menu option 22 installed wordpress sites have an cron script for auto updating wordpress plugins (and optionally wordpress itself at /root/tools/wp_updater_${vhostname}.sh)

    to enable wordpress core auto updates in that script uncomment these 4 lines too and remove hash # from front of them
    Code (Text):
    #/usr/bin/wp core check-update --allow-root
    #/usr/bin/wp core update --allow-root
    #/usr/bin/wp core update-db --allow-root
    #/usr/bin/wp core update --allow-root
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    some tidying up, you can remove this part
    Code (Text):
          # prevent access to ./directories and files
        location ~ (?:^|/)\. {
            deny all;
        }
    

    latest have it already set in drop.conf include file in vhosts created automatically

    this isn't needed entirely correct
    Code (Text):
        location / {
    
          if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
          }
    
          if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
          }
    
          if (!-f $request_filename){
            rewrite (.*) /index.php;
          }
    
          # block common exploits, sql injections etc
          include /usr/local/nginx/conf/block.conf;
        }
    

    can be replaced by just unless wp rocket related ?
    Code (Text):
    location / {
      try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # block common exploits, sql injections etc
      include /usr/local/nginx/conf/block.conf;
    }
    

    now what's contained in /usr/local/nginx/conf/rocket-nginx/rocket-nginx.conf include file as it's wp rocket plugin related which could be messing things up too.

    have you tried disabling wp rocket and see what happens with wordpress updates ? also try disabling block.conf include file and see what happens.
     
  6. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    I did those couple clean-ups and also updated the WP Rocket conf (only WP Rocket stuff in my site conf is the link to their conf). I'm suspecting the lack of updating the WP Rocket conf could have been my problem. But whatever the case, I won't know until another plugin or core update is available.

    But now restarting nginx gives me this error:

    Code:
    nginx: [warn] could not build optimal variables_hash, you should increase either variables_hash_max_size: 1024 or variables_hash_bucket_size: 64; ignoring variables_hash_bucket_size
     
  7. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    in /usr/local/nginx/conf/nginx.conf ensure the 1st 4 lines after http { is as follows
    Code (Text):
    http {
     map_hash_bucket_size 128;
     map_hash_max_size 4096;
     server_names_hash_bucket_size 128;
     server_names_hash_max_size 2048;
    

    and any duplicate instances of those names (with differing values further down in nginx.conf) are removed
     
  8. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    That's not working for me. But this does seem to be only a warning, so I'll ignore it for now. I'll post an update the next time I see a WP update come through.
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    be sure to restart nginx after the changes no duplicate hash variables set

    Centmin Mod nginx doesn't set that variable up so might want to use command below to find out which file sets this
    Code (Text):
    grep -Rn 'variables_hash' /usr/local/nginx/conf/*

    checking for duplicate hash_ variables
    Code (Text):
    grep -Rn 'hash_' /usr/local/nginx/conf/*
    
     
  10. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Ah re-reading that message fix is adding the variable variables_hash_max_size 1024

    so in /usr/local/nginx/conf/nginx.conf ensure the 1st 5 lines after http { is as follows
    Code (Text):
    http {
     map_hash_bucket_size 128;
     map_hash_max_size 4096;
     server_names_hash_bucket_size 128;
     server_names_hash_max_size 2048;
     variables_hash_max_size 1024;
    


    nginx hash tables Optimizations | NGINX

     
  11. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    Yeah, I put in that code and removed the later duplicate of one of those. But restarting nginx still gives me the same warning.

    Code:
    $ grep -Rn 'hash_' /usr/local/nginx/conf/
    /usr/local/nginx/conf/nginx.conf:22: map_hash_bucket_size 128;
    /usr/local/nginx/conf/nginx.conf:23: map_hash_max_size 4096;
    /usr/local/nginx/conf/nginx.conf:24: server_names_hash_bucket_size 128;
    /usr/local/nginx/conf/nginx.conf:25: server_names_hash_max_size 2048;
    /usr/local/nginx/conf/nginx.conf:26: variables_hash_max_size 1024;
    /usr/local/nginx/conf/nginx.conf:100: types_hash_max_size 2048;
    
     
  12. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    what version of nginx ?
    Code (Text):
    nginx -V
     
  13. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    1.11.4
     
  14. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    strange then is it exactly same message or did the prompted recommended values change ? could be you need a higher value for variables_hash_max_size ?

    Module ngx_http_core_module

    ah so it defaults to 1024 already, so try 2048 value instead
     
  15. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    I've updated plugins several times and it seems this original problem is fixed. So it probably was Rocket-Nginx. However, I have yet to see a WordPress core update come through.
     
  16. eva2000

    eva2000 Administrator Staff Member

    54,865
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    6:05 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    probably
    come through from where, if there's wordpress core updates it should report in the dashboard in wp admin
     
  17. Daniel J. Lewis

    Daniel J. Lewis Award-winning podcaster and consultant

    117
    15
    18
    Oct 20, 2014
    Ratings:
    +33
    Local Time:
    4:05 PM
    1.8.0
    5.6
    I should've said it this way.

    I have yet to see whether a WordPress core update works properly, as there hasn't been one, yet, since I last had this problem. I'll repost when I have resolution.