From bb4f00194c899a26f87d1935adda12b516aefac4 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 4 Jul 2013 11:58:13 +0530 Subject: [PATCH] WPSUBDOMAIN Settings --- usr/local/sbin/easyengine | 163 ++++++++++++++---- .../easyengine/nginx/wpsubdomain/basic.conf | 30 ++++ .../easyengine/nginx/wpsubdomain/w3tc.conf | 52 ++++++ .../easyengine/nginx/wpsubdomain/wpfc.conf | 61 +++++++ .../easyengine/nginx/wpsubdomain/wpsc.conf | 55 ++++++ 5 files changed, 332 insertions(+), 29 deletions(-) create mode 100644 usr/share/easyengine/nginx/wpsubdomain/basic.conf create mode 100644 usr/share/easyengine/nginx/wpsubdomain/w3tc.conf create mode 100644 usr/share/easyengine/nginx/wpsubdomain/wpfc.conf create mode 100644 usr/share/easyengine/nginx/wpsubdomain/wpsc.conf diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 588f6e34..c3c1b018 100755 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -599,11 +599,11 @@ NGINXHELPER() # Setup Wordpress Network -WPSUBDIRNETWORK() +SETUPWPNETWORK() { # Prepare wp-config.php File Foe Wordpress Multisite With SubDirectory cd /var/www/$DOMAIN/htdocs || OwnError "Unable To Change Directory" - wp core install-network --title="$SITETITLE" || OwnError "Unable To Setup WordPress SubDirectory Network" + wp core install-network --title="$SITETITLE" $WPSUBDOMAINS || OwnError "Unable To Setup WordPress SubDirectory Network" sed -i "/WP_DEBUG/a \define('WP_ALLOW_MULTISITE', true);" /var/www/$DOMAIN/wp-config.php sed -i "/WP_ALLOW_MULTISITE/a \define('WPMU_ACCEL_REDIRECT', true);" /var/www/$DOMAIN/wp-config.php @@ -613,19 +613,6 @@ WPSUBDIRNETWORK() NGINXHELPER } -WPSUBDOMAINNETWORK() -{ - # Prepare wp-config.php File Foe Wordpress Multisite With SubDirectory - cd /var/www/$DOMAIN/htdocs || OwnError "Unable To Change Directory" - wp core install-network --title="$SITETITLE" --subdomains || OwnError "Unable To Setup WordPress SubDirectory Network" - - sed -i "/WP_DEBUG/a \define('WP_ALLOW_MULTISITE', true);" /var/www/$DOMAIN/wp-config.php - sed -i "/WP_ALLOW_MULTISITE/a \define('WPMU_ACCEL_REDIRECT', true);" /var/www/$DOMAIN/wp-config.php - - # Remove index.php from permalink - # Install Nginx Helper - NGINXHELPER -} @@ -1124,7 +1111,7 @@ then # Congigure Variable SITENAMECHECK=$5 NGINXCONF=$3/basic.conf - echo "SITENAMECHECK = $SITENAMECHECK AND NGINXCONF = $NGINXCONF" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup Basic Nginx SETUPDOMAIN @@ -1140,7 +1127,7 @@ then # Congigure Variable SITENAMECHECK=$5 NGINXCONF=$3/w3tc.conf - echo "SITENAMECHECK = $SITENAMECHECK AND NGINXCONF = $NGINXCONF" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup W3 Total Cahe Nginx SETUPDOMAIN @@ -1163,7 +1150,7 @@ then # Congigure Variable SITENAMECHECK=$5 NGINXCONF=$3/wpsc.conf - echo "SITENAMECHECK = $SITENAMECHECK AND NGINXCONF = $NGINXCONF" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup WP Super Cahe Nginx SETUPDOMAIN @@ -1186,7 +1173,7 @@ then # Congigure Variable SITENAMECHECK=$5 NGINXCONF=$3/wpfc.conf - echo "SITENAMECHECK = $SITENAMECHECK AND NGINXCONF = $NGINXCONF" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup Fastcgi Cahe Nginx SETUPDOMAIN @@ -1216,13 +1203,13 @@ then # Congigure Variable SITENAMECHECK=$5 NGINXCONF=$3/basic.conf - echo "SITENAMECHECK = $SITENAMECHECK AND NGINXCONF = $NGINXCONF" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup Domain WordPress & Database SETUPDOMAIN # Setup WordPress SubDirectory Network - WPSUBDIRNETWORK + SETUPWPNETWORK PERMISSIONANDGIT # Setup phpMyAdmin @@ -1239,13 +1226,13 @@ then SITENAMECHECK=$5 NGINXCONF=$3/w3tc.conf NETWORKACTIVATE="--network" - echo "SITENAMECHECK = $SITENAMECHECK NGINXCONF = $NGINXCONF AND NETWORKACTIVATE = $NETWORKACTIVATE" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup Domain WordPress & Database SETUPDOMAIN # Setup WordPress SubDirectory Network - WPSUBDIRNETWORK + SETUPWPNETWORK TOTALCACHENGINX PERMISSIONANDGIT @@ -1269,13 +1256,13 @@ then SITENAMECHECK=$5 NGINXCONF=$3/wpsc.conf NETWORKACTIVATE="--network" - echo "SITENAMECHECK = $SITENAMECHECK NGINXCONF = $NGINXCONF AND NETWORKACTIVATE = $NETWORKACTIVATE" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup Domain WordPress & Database SETUPDOMAIN # Setup WordPress SubDirectory Network - WPSUBDIRNETWORK + SETUPWPNETWORK SUPERCACHENGINX PERMISSIONANDGIT @@ -1299,13 +1286,13 @@ then SITENAMECHECK=$5 NGINXCONF=$3/wpfc.conf NETWORKACTIVATE="--network" - echo "SITENAMECHECK = $SITENAMECHECK NGINXCONF = $NGINXCONF AND NETWORKACTIVATE = $NETWORKACTIVATE" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" # Setup Domain WordPress & Database SETUPDOMAIN # Setup WordPress SubDirectory Network - WPSUBDIRNETWORK + SETUPWPNETWORK TOTALCACHENGINX PERMISSIONANDGIT @@ -1325,9 +1312,127 @@ then fi - #elif [ "$3" = "wpsubdomain" ] - #then + elif [ "$3" = "wpsubdomain" ] + then + + if [ "$4" = "basic" ] + then + + # Congigure Variable + SITENAMECHECK=$5 + NGINXCONF=$3/basic.conf + WPSUBDOMAINS="--subdomains" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" + + # Setup Domain WordPress & Database + SETUPDOMAIN + + # Setup WordPress SubDirectory Network + SETUPWPNETWORK + PERMISSIONANDGIT + + # Setup phpMyAdmin + ln -s /usr/share/phpmyadmin /var/www/$DOMAIN/htdocs/ + + # Display Success Message + echo + echo -e "\033[34m Successfully Created New $3 $4 Website: http://$DOMAIN \e[0m" + + elif [ "$4" = "w3tc" ] + then + + # Congigure Variable + SITENAMECHECK=$5 + NGINXCONF=$3/w3tc.conf + WPSUBDOMAINS="--subdomains" + NETWORKACTIVATE="--network" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" + + # Setup Domain WordPress & Database + SETUPDOMAIN + + # Setup WordPress SubDirectory Network + SETUPWPNETWORK + TOTALCACHENGINX + PERMISSIONANDGIT + + # Setup phpMyAdmin + ln -s /usr/share/phpmyadmin /var/www/$DOMAIN/htdocs/ + + # Display WordPress Plugin Configuration Message + echo + echo -e "\033[34m Please Configure The Following Settings... \e[0m" + echo -e "\033[34m Permalink Settings: http://$DOMAIN/wp-admin/options-permalink.php \e[0m" + echo -e "\033[34m W3 Total Cache: http://$DOMAIN/wp-admin/network/admin.php?page=w3tc_general \e[0m" + + # Display Success Message + echo + echo -e "\033[34m Successfully Created New $3 $4 Website: http://$DOMAIN \e[0m" + elif [ "$4" = "wpsc" ] + then + + # Congigure Variable + SITENAMECHECK=$5 + NGINXCONF=$3/wpsc.conf + WPSUBDOMAINS="--subdomains" + NETWORKACTIVATE="--network" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" + + # Setup Domain WordPress & Database + SETUPDOMAIN + + # Setup WordPress SubDirectory Network + SETUPWPNETWORK + SUPERCACHENGINX + PERMISSIONANDGIT + + # Setup phpMyAdmin + ln -s /usr/share/phpmyadmin /var/www/$DOMAIN/htdocs/ + + # Display WordPress Plugin Configuration Message + echo + echo -e "\033[34m Please Configure The Following Settings... \e[0m" + echo -e "\033[34m Permalink Settings: http://$DOMAIN/wp-admin/options-permalink.php \e[0m" + echo -e "\033[34m WP Super Cache: http://$DOMAIN/wp-admin/network/settings.php?page=wpsupercache \e[0m" + + # Display Success Message + echo + echo -e "\033[34m Successfully Created New $3 $4 Website: http://$DOMAIN \e[0m" + + elif [ "$4" = "wpfc" ] + then + + # Congigure Variable + SITENAMECHECK=$5 + NGINXCONF=$3/wpfc.conf + WPSUBDOMAINS="--subdomains" + NETWORKACTIVATE="--network" + echo -e " SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE" + + # Setup Domain WordPress & Database + SETUPDOMAIN + + # Setup WordPress SubDirectory Network + SETUPWPNETWORK + TOTALCACHENGINX + PERMISSIONANDGIT + + # Setup phpMyAdmin + ln -s /usr/share/phpmyadmin /var/www/$DOMAIN/htdocs/ + + # Display WordPress Plugin Configuration Message + echo + echo -e "\033[34m Please Configure The Following Settings... \e[0m" + echo -e "\033[34m Permalink Settings: http://$DOMAIN/wp-admin/options-permalink.php \e[0m" + echo -e "\033[34m Nginx Helper: http://$DOMAIN/wp-admin/network/settings.php?page=nginx \e[0m" + echo -e "\033[34m W3 Total Cache: http://$DOMAIN/wp-admin/network/admin.php?page=w3tc_general \e[0m" + + # Display Success Message + echo + echo -e "\033[34m Successfully Created New $3 $4 Website: http://$DOMAIN \e[0m" + + fi fi fi diff --git a/usr/share/easyengine/nginx/wpsubdomain/basic.conf b/usr/share/easyengine/nginx/wpsubdomain/basic.conf new file mode 100644 index 00000000..dcf57d3a --- /dev/null +++ b/usr/share/easyengine/nginx/wpsubdomain/basic.conf @@ -0,0 +1,30 @@ +# WPSUBDOMAIN BASIC NGINX CONFIGURATION +server { + + # Uncomment The Following Line For Domain Mapping + # listen 80 default_server; + + server_name example.com *.example.com; + + # Uncomment The Following Line For Domain Mapping + #server_name_in_redirect off; + + access_log /var/log/nginx/example.com.access.log; + error_log /var/log/nginx/example.com.error.log; + + root /var/www/example.com/htdocs; + index index.php index.htm index.html; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri /index.php; + include fastcgi_params; + fastcgi_pass php; + } + + include /etc/nginx/common/locations.conf; + +} diff --git a/usr/share/easyengine/nginx/wpsubdomain/w3tc.conf b/usr/share/easyengine/nginx/wpsubdomain/w3tc.conf new file mode 100644 index 00000000..fc7b7d82 --- /dev/null +++ b/usr/share/easyengine/nginx/wpsubdomain/w3tc.conf @@ -0,0 +1,52 @@ +# WPSUBDOMAIN W3 TOTAL CACHE NGINX CONFIGURATION +server { + + # Uncomment The Following Line For Domain Mapping + # listen 80 default_server; + + server_name example.com *.example.com; + + # Uncomment The Following Line For Domain Mapping + #server_name_in_redirect off; + + access_log /var/log/nginx/example.com.access.log; + error_log /var/log/nginx/example.com.error.log; + + root /var/www/example.com/htdocs; + index index.php index.htm index.html; + + set $cache_uri $request_uri; + + # POST Requests And Urls With A Query String Should Always Go To PHP + if ($request_method = POST) { + set $cache_uri 'null cache'; + } + + if ($query_string != "") { + set $cache_uri 'null cache'; + } + + # Don't Cache Uris Containing The Following Segments + if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $cache_uri 'null cache'; + } + + # Don't Use The Cache For Logged In Users Or Recent Commenters + if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { + set $cache_uri 'null cache'; + } + + # Use Cached Or Actual File If They Exists, Otherwise Pass Request To WordPress + location / { + try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args; + } + + location ~ .php$ { + try_files $uri /index.php; + include fastcgi_params; + fastcgi_pass php; + } + + include /etc/nginx/common/locations.conf; + +} diff --git a/usr/share/easyengine/nginx/wpsubdomain/wpfc.conf b/usr/share/easyengine/nginx/wpsubdomain/wpfc.conf new file mode 100644 index 00000000..b110f8d4 --- /dev/null +++ b/usr/share/easyengine/nginx/wpsubdomain/wpfc.conf @@ -0,0 +1,61 @@ +# WPSUBDOMAIN FAST CGI NGINX CONFIGURATION +server { + + # Uncomment The Following Line For Domain Mapping + # listen 80 default_server; + + server_name example.com *.example.com; + + # Uncomment The Following Line For Domain Mapping + #server_name_in_redirect off; + + access_log /var/log/nginx/example.com.access.log; + error_log /var/log/nginx/example.com.error.log; + + root /var/www/example.com/htdocs; + index index.php index.htm index.html; + + set $skip_cache 0; + + # 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 ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.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") { + set $skip_cache 1; + } + + # Use Cached Or Actual File If They Exists, Otherwise Pass Request To WordPress + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ .php$ { + try_files $uri /index.php; + include fastcgi_params; + fastcgi_pass php; + + fastcgi_cache_bypass $skip_cache; + fastcgi_no_cache $skip_cache; + + fastcgi_cache WORDPRESS; + fastcgi_cache_valid 60m; + } + + location ~ /purge(/.*) { + fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; + } + + include /etc/nginx/common/locations.conf; +} diff --git a/usr/share/easyengine/nginx/wpsubdomain/wpsc.conf b/usr/share/easyengine/nginx/wpsubdomain/wpsc.conf new file mode 100644 index 00000000..d34f45f0 --- /dev/null +++ b/usr/share/easyengine/nginx/wpsubdomain/wpsc.conf @@ -0,0 +1,55 @@ +# WPSUBDOMAIN WP SUPER CACHE NGINX CONFIGURATION +server { + + # Uncomment The Following Line For Domain Mapping + # listen 80 default_server; + + server_name example.com *.example.com; + + # Uncomment The Following Line For Domain Mapping + #server_name_in_redirect off; + + access_log /var/log/nginx/example.com.access.log; + error_log /var/log/nginx/example.com.error.log; + + root /var/www/example.com/htdocs; + index index.php index.htm index.html; + + set $cache_uri $request_uri; + + # POST Requests And Urls With A Query String Should Always Go To PHP + if ($request_method = POST) { + set $cache_uri 'null cache'; + } + + if ($query_string != "") { + set $cache_uri 'null cache'; + } + + # Don't Cache Uris Containing The Following Segments + if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $cache_uri 'null cache'; + } + + # Don't Use The Cache For Logged In Users Or Recent Commenters + if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { + set $cache_uri 'null cache'; + } + + # Use Cached Or Actual File If They Exists, Otherwise Pass Request To WordPress + location / { + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args; + } + + location ~ .php$ { + try_files $uri /index.php; + include fastcgi_params; + fastcgi_pass php; + + # Following Line Is Needed By WP SUPER CACHE Plugin + fastcgi_param SERVER_NAME $http_host; + } + + include /etc/nginx/common/locations.conf; + +}