views:

1533

answers:

2

Hi all, I am currently working on my Wordpress blog, which is hosted on a VPS.NET VPS with Nginx as front end to Apache to serve static files, while Apache takes care of the PHP in FastCGI. This seems to be working great, however I haven't yet managed to have Nginx serve WP-SuperCache files as well, which I would like for maximum performance (I am not planning to completely replace Apache with Nginx right now because I've got a Virtualmin license and it does not support Nginx). I have tried a lot of rules found here and there but in the end none worked for me or I am missing something. If Apache is stopped, in fact, I can still get images, stylesheets and javascript delivered to the browser by Nginx directly. But if I try to surf the blog (with pages cached for sure by WP-SuperCache) with Apache stopped, all I get from Nginx is a "502 bad gateway". Any ideas would be greatly appreciated. Many thanks in advance.

A: 

It seems silly to run Nginx through Apache.

Set up Nginx to serve up the php and dynamic pages itself and you'll have a much faster service and won't have the problem where apache dies and leaves your webserver(Nginx) hanging.

If your admin panel doesn't support this, you probably should only be using apache in the first place. Either do one or the other, both is just asking for problems.

Kekoa
Well, I have heard often that nginx by itlsef would be a more performant way of serving php pages as well as static files, but in some other cases I've read/heard of people having trouble with this setup.Anyway, I would really like to get rid of Apache for a number of reasons, but I love Virtualmin and the ease of administration it gives me for various tasks, and so on, and I have got a Pro license which I've paid for. So it would basically be a waste of money to have Virtualmin and not to use it. For the time being, I'd like to get nginx to work with Super Cache files at least.
Vito Botta
A: 

Hi Vito,

Nginx can handle your fastCGI. Bundled with Nginx, generally, all Apache does is cost you resources.

Regarding WP Super Cache, if you create a new file and paste this, it'll give you both that and, while we're about 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, goto your virtual host file, or nginx.conf if you bundle 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 called the file we created, and given a path relative to that I've shown.

Then restart Nginx and turn on WP Super Cache plugin and, for the pretty links, add a permalink structure.


Fact is, there's a lot to know about to get the Nginx install right, especially with WordPress and to configure fastCGI. If you like, this would be a good start for you...

.. Setup WordPress on NGINX (FURLs & Cache) - VPS Bible Pt 13

Re. Virtualmin .. I understand you want a CP, but truth is, the resource cost is greater than the cost of the software .. plus it takes way longer to do stuff with a CP.

I'm currently publishing a 21 part VPS Admin series which addresses the lack of an Nginx CP .. that'll be all you need, frankly.

Given a week or two, I challenge you to tell me it's quicker or otherwise better to use a CP :)

the_guv
Sorry for the delay, I have been busy with so many thinks lately. I did manage to get nginx working very well on its own, so thank you for the advice. However, I ended up with using Rackspace's Cloud Sites service for the time being; unfortunately I had wasted a lot of time, I have a number of projects to work on, and realized it is not convenient for me at this stage to spend too much time with administration etc. Nginx was very fast! But sadly I got stuck with issues with PHP-FPM processes, etc. Thanks, anyway.
Vito Botta