Want more timely Centmin Mod News Updates?
Become a Member

Wordpress How to remove Redis Nginx level caching from centmin.sh menu option 22 wordpress installs

Discussion in 'Blogs & CMS usage' started by eva2000, Apr 16, 2020.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    53,142
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    5:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    If you can Centmin Mod 123.09beta01 or new version's centmin.sh menu option 22 Wordpress auto installer and selected Redis Nginx level guest full HTML page caching method at install time (shown below) and want to later remove the Redis Nginx level caching, then this guide is for you.
    Code (Text):
    Default is to install KeyCDN WP Cache Enabler Plugin
    as it's more stable and reliable than WP Super Cache.
    Redis cache may have issues with caching due to long 6hr cache TTL
    You can select which caching method to use below:
    
    --------------------------------------------------------
            Wordpress Caching            
    --------------------------------------------------------
    1) KeyCDN Cache Enabler
    2) Redis Nginx Level Caching
    3) Wordpress Super Cache
    --------------------------------------------------------
    Enter option [ 1 - 3 ] 2
    

    If you want to try other Wordpress caching plugin methods like W3 Total Cache, WP-Rocket etc, then you'd need to remove Redis Nginx level guest full HTML page caching method configuration from your domain's Nginx vhost config file as they will conflict as they would both technically do the same thing for caching at least.

    Removing Redis Nginx Level Cache



    Removing Redis Nginx level caching will involve modifying your centmin.sh menu option 22 Wordpress install's auto generated Nginx vhost config file which would be at /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.ssl.conf for HTTPS sites and /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.conf for non-HTTPS sites.

    For purposes of this example, I will be referring to HTTPS sites Nginx vhost config file at /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.ssl.conf and the Wordpress Nginx site domain is redis-nginx.domain.com.

    Step 1. Comment out with a hash # in front to disable /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/rediscache_redis-nginx.domain.com.conf include file line

    Change from
    Code (Text):
    include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/rediscache_redis-nginx.domain.com.conf;
    

    to
    Code (Text):
     #include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/rediscache_redis-nginx.domain.com.conf;  


    Step 2.
    Change location / {} context's try_files format line from Nginx level redis wordpress version to default Wordpress permalinks try_files line format version.


    Change from
    Code (Text):
      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;
      }
    

    to
    Code (Text):
      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;
      }
    

    so you disable
    Code (Text):
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    

    and have enabled the default Wordpress permalink version
    Code (Text):
      # Wordpress Permalinks
      try_files $uri $uri/ /index.php?q=$uri&$args;
    


    Step 3. Change all references to include /usr/local/nginx/conf/php-rediscache.conf file to non-redis cache /usr/local/nginx/conf/php.conf include file

    Change all references from
    Code (Text):
    include /usr/local/nginx/conf/php-rediscache.conf;

    to
    Code (Text):
    include /usr/local/nginx/conf/php.conf;


    Step 4. Optionally remove all references to php-wpsc.conf include file which is already disabled with comment hash # in front but you can tidy up your vhost if you remove all references

    Code (Text):
    #include /usr/local/nginx/conf/php-wpsc.conf;


    Step 5. Restart Nginx, PHP-FPM and Flush Redis Cache

    Code (Text):
    redis-cli flushall
    nprestart

    or
    Code (Text):
    redis-cli flushall
    service nginx restart
    service php-fpm restart
     
    Last edited: Apr 16, 2020
  2. eva2000

    eva2000 Administrator Staff Member

    53,142
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    5:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Here's a universal diff compare of before and after Redis Nginx level cache from above Nginx vhost file which make it clearer where negative prefix against a line is the before state and postive prefix against a line is after remove state of the particular line
    Code (Text):
    diff -u /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.ssl.conf /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.ssl.conf-remove-redis-cache
    --- /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.ssl.conf        2020-04-15 21:43:41.029843782 +0000
    +++ /usr/local/nginx/conf/conf.d/redis-nginx.domain.com.ssl.conf-remove-redis-cache     2020-04-15 21:48:18.669210865 +0000
    @@ -70,7 +70,7 @@
       #include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/wpcacheenabler_redis-nginx.domain.com.conf;
       #include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/wpsupercache_redis-nginx.domain.com.conf;
       # https://community.centminmod.com/posts/18828/
    -  include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/rediscache_redis-nginx.domain.com.conf;
    +  #include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/rediscache_redis-nginx.domain.com.conf;
     
       location / {
       include /usr/local/nginx/conf/503include-only.conf;
    @@ -86,11 +86,11 @@
       #try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
     
       # Wordpress Permalinks
    -  #try_files $uri $uri/ /index.php?q=$uri&$args;
    +  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;
    +  #try_files $uri $uri/ /index.php?$args;
     
       }
     
    @@ -99,39 +99,35 @@
         #limit_conn xwpconlimit 30;
         #auth_basic "Private";
         #auth_basic_user_file /home/nginx/domains/redis-nginx.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;
    +    include /usr/local/nginx/conf/php.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/php.conf;
     }
     
     location ~* /wp-admin/(load-scripts\.php) {
         limit_req zone=xwprpc burst=5 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/php.conf;
     }
     
     location ~* /wp-admin/(load-styles\.php) {
         limit_req zone=xwprpc burst=5 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/php.conf;
     }
     
       include /usr/local/nginx/conf/wpincludes/redis-nginx.domain.com/wpsecure_redis-nginx.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/php.conf;
       include /usr/local/nginx/conf/pre-staticfiles-local-redis-nginx.domain.com.conf;
       include /usr/local/nginx/conf/pre-staticfiles-global.conf;
       include /usr/local/nginx/conf/staticfiles.conf;
     
Thread Status:
Not open for further replies.