Nginx (as Apache frontend) for WP Super Cache static files
I am currently working on my Wordpress blog, which is hosted on a VPS.NET VPS with Nginx as the front-end for Apache to serve static files, while Apache takes care of PHP in FastCGI. It seems to work fine, however I have not yet been able to get Nginx to serve the WP-SuperCache files that I would like for maximum performance (I am not planning on completely replacing Apache Nginx right now because I have a Virtualmin license and it does not support Nginx). I tried many rules found here and there, but in the end none worked for me, or am I missing something. If Apache is stopped, in fact, I can still get images, stylesheets, and javascript passed directly to the Nginx browser. But if I try to work on the blog (with pages,cached for sure WP-SuperCache) when Apache stopped, all I get from Nginx is "502 bad gateway". Any ideas are greatly appreciated. Thank you very much in advance.
a source to share
Nginx can handle your fastCGI. Bundled with Nginx, as a rule, all Apache really costs you resources.
As far as WP Super Cache is concerned, if you create a new file and paste it, it will give you both, and while we're on it, FURLs ...
# if the requested file exists, return it immediately
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri '';
}
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}
# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# all other requests go to Wordpress
if (!-e $request_filename) {
rewrite . /index.php last;
}
Now go to your virtual host file or nginx.conf if you linked your sites and add a line like ..
# Wordpress WP Super Cache plugin and permalinks.
include /usr/local/nginx/conf/wordpress_params.super_cache;
.. where wordpress_params.super_cache is what you named the file we created and set the path I showed.
Then restart Nginx and enable WP Super Cache plugin and add permalink structure for good links.
The fact is, there is a lot to know about how to properly install Nginx, especially in WordPress, and configure FastCGI. If you like it, this will be a good start for you ...
.. Installing WordPress in NGINX (FURLs and cache) - VPS Bible Pt 13
Re. Virtualmin .. I understand that you want CP, but the truth is that the resource cost is greater than the software cost. It also takes longer to work with the CP.
I am currently posting 21 parts of VPS Admin addressing the lack of Nginx CP .. that will be all you need to be honest.
Given a week or two, I urge you to tell me about it faster or else it's better to use CP :)
a source to share
It seems silly to run Nginx through Apache.
Configure Nginx to serve php itself and dynamic pages, and you will have a much faster service and you won't have a problem when apache dies and leaves your web server (Nginx).
If your admin panel doesn't support this, you should probably only use apache in the first place. Either one or the other, both are just asking problems.
a source to share