From cef1fed914531d27d67d2c05f03c1a53a1d85592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Mart=C3=ADnez=20Ochoa?= Date: Mon, 19 Mar 2018 14:32:37 -0700 Subject: [PATCH] redis plugin installed Now Redis Object Cache Plugin is automatically installed when WP Cache is enabled. --- lib/sites | 47 +++++++++++++++++++++++++++++++++-------------- plugins/site | 8 ++++---- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/lib/sites b/lib/sites index e7a1d46..abddf1a 100644 --- a/lib/sites +++ b/lib/sites @@ -6,19 +6,38 @@ source /opt/webinoly/lib/general -nginx_helper_plugin() { - # Download WP (latest version) - sudo wget --timeout=15 -qrO /var/www/$domain/htdocs/nginx-helper-plugin.zip https://downloads.wordpress.org/plugin/nginx-helper.latest-stable.zip - sudo unzip -qq /var/www/$domain/htdocs/nginx-helper-plugin.zip -d /var/www/$domain/htdocs/wp-content/plugins/ - sudo rm /var/www/$domain/htdocs/nginx-helper-plugin.zip - echo "" - echo "${gre} Nginx Helper Plugin has been installed!" - echo " Please, activate this plugin for a better experience with FastCgi Cache." - echo "${blu} ** IMPORTANT - Plugin Settings **" - echo "- The “Caching Method” should be set to “Nginx FastCgi Cache”." - echo "- Support for purge/url method has been disabled because it is considered a security risk." - echo "- The Purge Method should be set to “Delete local server cache file” " - echo "${end}" +wp_cache_plugins() { + if [[ ! -d /var/www/$domain/htdocs/wp-content/plugins/nginx-helper ]]; then + # Download Nginx Helper Plugin + sudo wget --timeout=15 -qrO /var/www/$domain/htdocs/nginx-helper-plugin.zip https://downloads.wordpress.org/plugin/nginx-helper.latest-stable.zip + sudo unzip -qq /var/www/$domain/htdocs/nginx-helper-plugin.zip -d /var/www/$domain/htdocs/wp-content/plugins/ + sudo rm /var/www/$domain/htdocs/nginx-helper-plugin.zip + echo "" + echo "${gre} Nginx Helper Plugin has been installed!" + echo " Please, activate this plugin for a better experience with FastCgi Cache." + echo "${blu} ** IMPORTANT - Plugin Settings **" + echo "- The “Caching Method” should be set to “Nginx FastCgi Cache”." + echo "- Support for purge/url method has been disabled because it is considered a security risk." + echo "- The Purge Method should be set to “Delete local server cache file” " + echo "${end}" + else + echo "${red}Nginx Helper Plugin is already installed!${end}" + fi + + if [[ ! -d /var/www/$domain/htdocs/wp-content/plugins/redis-cache ]]; then + # Download Redis Object Cache Plugin + sudo wget --timeout=15 -qrO /var/www/$domain/htdocs/redis-cache-plugin.zip https://downloads.wordpress.org/plugin/redis-cache.latest-stable.zip + sudo unzip -qq /var/www/$domain/htdocs/redis-cache-plugin.zip -d /var/www/$domain/htdocs/wp-content/plugins/ + sudo rm /var/www/$domain/htdocs/redis-cache-plugin.zip + echo "" + echo "${gre} Redis Object Cache Plugin has been installed!" + echo " Please, activate this plugin for a better experience with WordPress Object Cache." + echo "${blu} ** IMPORTANT - Plugin Settings **" + echo "- Go to “Menu > Settings > Redis” and be sure that Object Cache is enabled. " + echo "${end}" + else + echo "${red}Redis Object Cache Plugin is already installed!${end}" + fi } @@ -457,7 +476,7 @@ createsite() { # Activate FastCgi cache if [[ "$cache" == "-cache" && "$wp" == [123] ]]; then sudo sed -i '/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain - nginx_helper_plugin + wp_cache_plugins fi echo "${gre}Site $domain has been successfully created!${end}" diff --git a/plugins/site b/plugins/site index c32bd18..88c98df 100644 --- a/plugins/site +++ b/plugins/site @@ -299,14 +299,14 @@ elif [[ "$type" == "-cache" && -a /etc/nginx/sites-available/$domain ]]; then iswp=$( grep -F "wpcommon.conf" /etc/nginx/sites-available/$domain ) if [[ -n $isphp && -n $iswp ]]; then sudo sed -i '/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain - if [[ ! -d /var/www/$domain/htdocs/wp-content/plugins/nginx-helper ]]; then + if [[ ! -d /var/www/$domain/htdocs/wp-content/plugins/nginx-helper || ! -d /var/www/$domain/htdocs/wp-content/plugins/redis-cache ]]; then echo "${gre}" - echo "We recommend Nginx Helper Plugin as an easy way to manage FastCGI Cache on your site." - echo "${blu} Do you want to install it now [Y/n]? " + echo "We recommend Nginx Helper Plugin and Redis Object Cache Plugin as an easy way to manage FastCGI and Redis Cache on your WordPress site." + echo "${blu}Do you want to install it now [Y/n]? ${end}" while read -r -n 1 -s answer; do answer=${answer:-y} if [[ $answer = [YyNn] ]]; then - [[ $answer = [Yy] ]] && nginx_helper_plugin + [[ $answer = [Yy] ]] && wp_cache_plugins break fi done