Welcome to Centmin Mod Community
Become a Member

Beta Branch Centmin Mod 123.09beta01 centmin.sh menu option 22 - add Redis cache support

Discussion in 'Beta release code' started by eva2000, Sep 22, 2016.

  1. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Just updated Centmin Mod 123.09beta01's centmin.sh menu option 22 wordpress auto installer with Redis cache nginx level support out of the box. You can select the options via a shell menu :)


    Code (Text):
    --------------------------------------------------------
         Centmin Mod Menu 123.09beta01 centminmod.com     
    --------------------------------------------------------
    1).  Centmin Install
    2).  Add Nginx vhost domain
    3).  NSD setup domain name DNS
    4).  Nginx Upgrade / Downgrade
    5).  PHP Upgrade / Downgrade
    6).  XCache Re-install
    7).  APC Cache Re-install
    8).  XCache Install
    9).  APC Cache Install
    10). Memcached Server Re-install
    11). MariaDB 5.2/5.5 & 10.x Upgrade Sub-Menu
    12). Zend OpCache Install/Re-install
    13). Install/Reinstall Redis PHP Extension
    14). SELinux disable
    15). Install/Reinstall ImagicK PHP Extension
    16). Change SSHD Port Number
    17). Multi-thread compression: pigz,pbzip2,lbzip2...
    18). Suhosin PHP Extension install
    19). Install FFMPEG and FFMPEG PHP Extension
    20). NSD Install/Re-Install
    21). Update - Nginx + PHP-FPM + Siege
    22). Add Wordpress Nginx vhost + Cache Plugin
    23). Update Centmin Mod Code Base
    24). Exit
    --------------------------------------------------------
    Enter option [ 1 - 24 ] 22
    --------------------------------------------------------


    Code (Text):
    -------------------------------------------------------------
    Setup full Nginx vhost + Wordpress + WP Plugins
    -------------------------------------------------------------
    
    Enter vhost domain name you want to add (without www. prefix): newdomain.com
    
    Create a self-signed SSL certificate Nginx vhost? [y/n]: n
    Theme Setup:
    Install CyberChimps Responsive Theme (cyberchimps.com/responsive-theme/) [y/n]: n
    
    Wordpress Setup:
    Set custom WP Admin Display Name ? [y/n]: n
    Install Wordpress in subdirectory /blog ? [y/n]: n
    Disable Auto Generated WP Admin Username / Password ? [y/n]: n
    Disable wp-login.php password protection ? (less security) [y/n]: y
    Enter email address for Admin User for Wordpress Installation: MYEMAIL@DOMAIN.COM
    
    Default is to install KeyCDN WP Cache Enabler Plugin
    as it's more stable and reliable than WP Super Cache.
    You can select which caching method to use below:
    
    --------------------------------------------------------
            Wordpress Caching               
    --------------------------------------------------------
    1). KeyCDN Cache Enabler (default & recommended)
    2). Redis Nginx Level Caching
    3). Wordpress Super Cache
    --------------------------------------------------------
    Enter option [ 1 - 3 ] 


    Still needs some testing to polish off. But that's where you folks come in ;) :D
     
  2. jcat

    jcat Member

    153
    22
    18
    Jun 21, 2015
    New Jersey
    Ratings:
    +64
    Local Time:
    2:38 AM
    Woohoo this is an awesome addition :) (y)(y)(y)
     
  3. tjk

    tjk Member

    76
    16
    8
    Jun 27, 2015
    Ratings:
    +27
    Local Time:
    2:38 AM
    Good news, assuming based on my feedback! :)
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Indeed :)
    Yup, was on the books, but brought it forward :D
     
  5. jcat

    jcat Member

    153
    22
    18
    Jun 21, 2015
    New Jersey
    Ratings:
    +64
    Local Time:
    2:38 AM
    I'm not sure if there were any changes made other than uncommenting and installing redis for you, but I noticed xmlrpc.php is being cached now although it is set to skip_cache in rediscache_domain.com.conf

    XML-RPC server accepts POST requests only.
    <!--Cached using Nginx-Helper on 2016-09-24 13:14:28. It took 0 queries executed in 0.279 seconds.-->
    <!--Visit Nginx Helper — WordPress Plugins for more details-->

    Weird right?

    This is causing issues with Jetpack
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  7. cloud9

    cloud9 Premium Member Premium Member

    431
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    7:38 AM
    1.25.3
    10.6.x
    We just need an out of the box Varnish Cache now :love:
     
  8. jcat

    jcat Member

    153
    22
    18
    Jun 21, 2015
    New Jersey
    Ratings:
    +64
    Local Time:
    2:38 AM
    This is a fresh OS and centmin install, was done yesterday using option 22

    UTC:

    Sep 23 20:04 centminmod_1.2.3-eva2000.09.001_230916-194043_wordpress_addvhost.log

    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 domain.com;
    #            return 301 $scheme://www.domain.com$request_uri;
    #       }
    
    server {
    
      server_name domain.com www.domain.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;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/domain.com/log/access.log main_ext buffer=256k flush=60m;
      error_log /home/nginx/domains/domain.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf;
      root /home/nginx/domains/domain.com/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;
    
      #include /usr/local/nginx/conf/wpincludes/domain.com/wpcacheenabler_domain.com.conf;
      #include /usr/local/nginx/conf/wpincludes/domain.com/wpsupercache_domain.com.conf;
      # https://community.centminmod.com/posts/18828/
      include /usr/local/nginx/conf/wpincludes/domain.com/rediscache_domain.com.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
    
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      #try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      try_files $uri $uri/ /index.php?$args;
    
      }
    
    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/domain.com/htpasswd_wplogin;
        #include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        #include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
      include /usr/local/nginx/conf/wpincludes/domain.com/wpsecure_domain.com.conf;
      #include /usr/local/nginx/conf/php-wpsc.conf;
      # https://community.centminmod.com/posts/18828/
      include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    Code:
    # Block nginx-help log from public viewing
    location ~* /wp-content/uploads/nginx-helper/ { deny all; }
    
    set $skip_cache 0;
    
    # exclude mobile devices from redis caching
    #if ($redis_device = mobile) { set $skip_cache 1; }
    
    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
      set $skip_cache 1;
    }
    
    if ($query_string != "") {
      set $skip_cache 1;
    }
    
    # Don't cache uris containing the following segments
    if ($request_uri ~* "\?add-to-cart=|/cart/|xmlrpc.php|/my-account/|/checkout/|/shop/checkout/|/store/checkout/|/customer-dashboard/|/addons/|/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
      set $skip_cache 1;
    }
    
    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|edd_items_in_cart|woocommerce_items_in_cart") {
      set $skip_cache 1;
    }
    
    location /redis-fetch {
      internal  ;
      set  $redis_key $args;
      redis_pass  redisbackend;
      redis_connect_timeout 60000;
      redis_read_timeout 60000;
      redis_send_timeout 60000;
    }
    
    location /redis-store {
      internal  ;
      set_unescape_uri $key $arg_key ;
      redis2_query set $key $echo_request_body;
      redis2_query expire $key 6h;
      redis2_pass  redisbackend;
      redis2_connect_timeout 60s;
      redis2_read_timeout 60s;
      redis2_send_timeout 60s;
    }
    
    location /redis-store-shortttl {
      internal  ;
      set_unescape_uri $key $arg_key ;
      redis2_query set $key $echo_request_body;
      redis2_query expire $key 3600;
      redis2_pass  redisbackend;
      redis2_connect_timeout 60s;
      redis2_read_timeout 60s;
      redis2_send_timeout 60s;
    }
    
     
  9. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Varnish cache you'd be on your own heh as it's server wide + need web specific varnish vcl rules. Something that folks need to be on top of.

    @jcat don't see anything there that would cause /xmlrpc.php file from being excluded from redis caching
    what is specific issue or error messages ?

    if you mean the extra 2 lines
    Code (Text):
    XML-RPC server accepts POST requests only.
    <!--Cached using Nginx-Helper on 2016-09-24 14:24:49. It took 15 queries executed in 0.044 seconds.-->
    <!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->

    at bottom, the in nginx-helper in wp admin disable adding them
     
  10. jcat

    jcat Member

    153
    22
    18
    Jun 21, 2015
    New Jersey
    Ratings:
    +64
    Local Time:
    2:38 AM
    Hmm I think I jumped the gun on this one. Been monitoring the access logs and I am seeing no hits from Jetpack, the DNS was changed but its been over 12 hours however I am thinking Jetpack is still hitting the old server.

    Jetpack doesn't give any helpful messages other than:

    We were unable to make an XML-RPC request to your website. Please make sure that XML-RPC is turned on and that Jetpack is installed, activated and connected with your WordPress.com account.

    Don't waste anymore time on this, my bad.
     
  11. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    centmin.sh menu option 22, auto installs disable-xml-rpc wp plugin too, so make sure you disable that if you need xmlrpc.php access

    and auto rate limits those requests, so make sure it isn't hitting the limit which defaults to 30 requests/s with 45 burst
    Code (Text):
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        #include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        include /usr/local/nginx/conf/php-rediscache.conf;
    }
     
  12. cloud9

    cloud9 Premium Member Premium Member

    431
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    7:38 AM
    1.25.3
    10.6.x
    Well if we had an option in centminmod to install varnish we cold have it install with the default vcl and have say a wordpress vcl file and other vcl files or vcl configs commented out - Yes on top of varnish but if you use it then like ssh you should know what your doing - depends really if many have any configs, wordpress is pretty default and loads on the net about vcl for wordpress including running nginx for the ssl and then varnish as the cache (as it doesnt do ssl although i believe v5 is getting there) - i used to run on varnish using unixy's vcl flavours (paid for) and to be honest it was very good, far better than memcache and other caching methods, although never tried redis

    Wordpress-Server-Configuration-Files/default.vcl at master · ewanleith/Wordpress-Server-Configuration-Files · GitHub

    WordpressDefaultVCLv4/default.vcl at master · StaymanHou/WordpressDefaultVCLv4 · GitHub
     
    Last edited: Sep 25, 2016
  13. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod already has Varnish official repo support - see Third Party YUM Repos with Centmin Mod - CentminMod.com LEMP Nginx web stack for CentOS Though it's for Varnish 3.x right now. You just need to install and configure it yourself. Besides me not wanting to provide support/troubleshooting for free for Varnish related issues, Varnish not supporting SSL is another factor. Pre-made Varnish VCL templates only get you so far for single web app configurations. What if a site has multiple web apps, wordpress front end, a forum software, then a shopping cart all on the same domain. End user needs to be be able to understand in detail how each web app and their corresponding cookies need to be tuned for Varnish VCL configurations.

    You could do it Unixy Varnish method of per user caching to overcome this and I also contributed suggestions/feedback to Unixy Varnish VCLs a few years back. But Unixy Varnish cache per user caching doesn't scale with very large amount of concurrent users - especially when there's a lot of requests hitting the backend PHP due low hit rates due to per user caching.

    Extensive thread at Installing Varnish Cache ? | Centmin Mod Community with my stance on Varnish Cache in Centmin Mod as being a end user task with requirements of them understanding what they're doing with Varnish VCL rules and configuration for their specific web apps :) That thread also highlights what kind of support load it would be for me if the folks don't know a thing about Varnish cache :D
     
  14. cloud9

    cloud9 Premium Member Premium Member

    431
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    7:38 AM
    1.25.3
    10.6.x
    Perhaps update the third party yum to v4 then ?

    V3 is quite old now

    Agree and i only have ever used it for single sites not multiples with different things running and that is where it is pretty awesome
     
  15. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  16. Jon Snow

    Jon Snow Active Member

    767
    157
    43
    Jun 30, 2017
    Ratings:
    +225
    Local Time:
    3:38 AM
    Nginx 1.13.9
    MariaDB 10.1.31
  17. eva2000

    eva2000 Administrator Staff Member

    53,278
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    4:38 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yup