Last active
August 29, 2015 13:56
-
-
Save centminmod/8996204 to your computer and use it in GitHub Desktop.
Instructions to switch from Centmin Mod Nginx based Wordpress WP-FFPC plugin configuration to Wordpress Super Cache plugin configuration. This is a quick and rough how to until the full auto installer outlined at https://blog.centminmod.com/194 is ready for release.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just deactivate WP-FFPC like any WP plugin and delete it. Then need to adjust your Nginx domain's Nginx vhost domain.conf file to format for WP Super Cache. Quick manual method for WP Super Cache install are the following commands via WP-CLI tool. | |
Assuming /home/nginx/domains/domainname.com/public/wp is your Wordpress install directory. If you haven't installed Wordpress yet follow only step #2 outlined at http://centminmod.com/nginx_configure_wordpress_ffpc_plugin.html | |
then type following commands in SSH window editing just your WPDIR variabvle to point to your domainname.com path where wordpress is installed. | |
WPDIR='/home/nginx/domains/domainname.com/public/wp' | |
CHOWNDFT='nginx:nginx' | |
cd $WPDIR | |
wp plugin install wp-super-cache --activate --allow-root | |
\cp -af wp-content/plugins/wp-super-cache/wp-cache-config-sample.php wp-content/wp-cache-config.php | |
\cp -af wp-content/plugins/wp-super-cache/advanced-cache.php wp-content/advanced-cache.php | |
mkdir -p wp-content/cache/ | |
mkdir -p wp-content/cache/supercache/ | |
chown -R $CHOWNDFT wp-content/ | |
chmod -R 0777 wp-content/cache/ | |
nginx vhost format for web root Wordpress install at / | |
edit /usr/local/nginx/conf/conf.d/domainname.com.conf to below format | |
------------------------------------------------- | |
server { | |
server_name domainname.com www.domainname.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/domainname.com/log/access.log combined buffer=32k; | |
error_log /home/nginx/domains/domainname.com/log/error.log; | |
root /home/nginx/domains/domainname.com/public; | |
include /usr/local/nginx/conf/wpsupercache.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; | |
} | |
include /usr/local/nginx/conf/wpsecure.conf; | |
include /usr/local/nginx/conf/staticfiles.conf; | |
include /usr/local/nginx/conf/php.conf; | |
include /usr/local/nginx/conf/drop.conf; | |
#include /usr/local/nginx/conf/errorpage.conf; | |
} | |
------------------------------------------------- | |
nginx vhost format for web root Wordpress install at /wp | |
edit /usr/local/nginx/conf/conf.d/domainname.com.conf to below format | |
------------------------------------------------- | |
server { | |
server_name domainname.com www.domainname.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/domainname.com/log/access.log combined buffer=32k; | |
error_log /home/nginx/domains/domainname.com/log/error.log; | |
root /home/nginx/domains/domainname.com/public; | |
include /usr/local/nginx/conf/wpsupercache.conf; | |
location /wp { | |
# Enables directory listings when index file not found | |
#autoindex on; | |
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /wp/index.php?q=$uri$is_args$args; | |
} | |
include /usr/local/nginx/conf/wpsecure.conf; | |
include /usr/local/nginx/conf/staticfiles.conf; | |
include /usr/local/nginx/conf/php.conf; | |
include /usr/local/nginx/conf/drop.conf; | |
#include /usr/local/nginx/conf/errorpage.conf; | |
} | |
------------------------------------------------- | |
create file at /usr/local/nginx/conf/wpsecure.conf with following contents | |
------------------------------------------------- | |
# Deny access to any files with a .php extension in the uploads directory | |
# Works in sub-directory installs and also in multisite network | |
location ~* /(?:uploads|files)/.*\.php$ { | |
deny all; | |
} | |
# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS! | |
location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ | |
{ | |
return 444; | |
} | |
#nocgi | |
location ~* \.(pl|cgi|py|sh|lua)$ { | |
return 444; | |
} | |
#disallow | |
location ~* (roundcube|webdav|smtp|http\:|soap|w00tw00t) { | |
return 444; | |
} | |
location ~ /(\.|wp-config.php|wp-config.txt|readme.html|license.txt) { deny all; } | |
------------------------------------------------- | |
create file at /usr/local/nginx/conf/wpsupercache.conf with following contents | |
------------------------------------------------- | |
set $cache_uri $request_uri; | |
if ($request_method = POST) { set $cache_uri 'null cache'; } | |
if ($query_string != "") { set $cache_uri 'null cache'; } | |
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $cache_uri 'null cache'; } | |
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { set $cache_uri 'null cache'; } | |
------------------------------------------------- | |
Then you need to login Wordpress admin | |
1. Enable Permalinks | |
2. Go to Super Cache plugin Easy tab and enable it by checking " Caching On (Recommended)" and hit Update Status | |
3. Then go to Advanced tab and check "Use mod_rewrite to serve cache files. (Recommended)" and hit Update Status | |
Then confirm WP Super Cache is working by checking page source code on Wordpress pages via SSH window type the following if Wordpress installed at http://domainname.com/wp/ | |
curl -S http://domainname.com/wp/ | tail -4 | |
you'll see output like below | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 7800 0 7800 0 0 83207 0 --:--:-- --:--:-- --:--:-- 83870 | |
<!-- Dynamic page generated in 0.091 seconds. --> | |
<!-- Cached page generated by WP-Super-Cache on 2014-02-14 05:18:47 --> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment