Nginx(作为Apache的前端)为WP Super Cache静态文件提供服务

时间:2009-05-19 20:26:13

标签: wordpress nginx

我目前正在使用我的Wordpress博客,该博客托管在VPS.NET VPS上,Nginx作为Apache的前端来提供静态文件,而Apache负责FastCGI中的PHP。这似乎工作得很好,但我还没有设法让Nginx提供WP-SuperCache文件,我希望获得最大性能(我不打算完全用Nginx替换Apache,因为我有Virtualmin许可证,它不支持Nginx)。 我已经尝试了很多在这里和那里发现的规则,但最终没有对我有用或者我错过了一些东西。 实际上,如果Apache停止了,我仍然可以直接通过Nginx将图像,样式表和javascript传送到浏览器。 但是如果我试图在Apache停止浏览博客(通过WP-SuperCache缓存的页面),我从Nginx获得的是“502坏网关”。 任何想法将不胜感激。 非常感谢提前。

2 个答案:

答案 0 :(得分:0)

通过Apache运行Nginx似乎很愚蠢。

设置Nginx以提供php和动态页面本身,你将拥有更快的服务,并且不会出现apache死亡并让你的web服务器(Nginx)挂起的问题。

如果您的管理员小组不支持此功能,您可能应该首先使用apache。无论是做其中一个,都只是在问问题。

答案 1 :(得分:0)

Nginx可以处理你的fastCGI。通常,与Nginx捆绑在一起,所有Apache都会花费您的资源。

关于WP超级缓存,如果你创建一个新文件并粘贴它,它会给你这两个,而我们就此而言,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;
}

现在,如果您捆绑了网站,请转到您的虚拟主机文件或nginx.conf,并添加一行代码..

# Wordpress WP Super Cache plugin and permalinks.
include /usr/local/nginx/conf/wordpress_params.super_cache;

..其中wordpress_params.super_cache就是你所谓的我们创建的文件,并给出了相对于我所展示的路径。

然后重新启动Nginx并打开WP Super Cache插件,对于漂亮的链接,添加永久链接结构。


事实上,有很多东西要知道如何正确安装Nginx,尤其是使用WordPress并配置fastCGI。如果你愿意,这对你来说是个好开始......

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

重新。 Virtualmin ..我知道你想要一个CP,但事实是,资源成本高于软件的成本..再加上使用CP的东西需要更长的时间。

我目前正在发布一个21部分的VPS Admin系列,它解决了缺少Nginx CP的问题。坦白地说,这就是你所需要的。

考虑一两个星期后,我向你发出挑战,告诉我使用CP更快或更好:)