繁体   English   中英

Nginx(作为 Apache 的前端)提供 WP 超级缓存 static 文件

[英]Nginx (as front end to Apache) to serve WP Super Cache static files

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. 这似乎工作得很好,但是我还没有设法让 Nginx 也服务 WP-SuperCache 文件,我希望获得最佳性能(我不打算用 Z62E0B5B350C9E3D2C19 完全替换 Apache 因为现在得到了Virtualmin 许可证,它不支持 Nginx)。 我已经尝试了很多在这里和那里找到的规则,但最后没有一个对我有用,或者我错过了一些东西。 如果Apache停止了,其实我还是可以直接得到Nginx传递给浏览器的图片、样式表和javascript。 但是,如果我尝试在 Apache 停止的情况下浏览博客(页面肯定被 WP-SuperCache 缓存),我从 Nginx 得到的只是“502 坏网关”。 任何想法将不胜感激。 提前谢谢了。

Nginx可以处理您的fastCGI。 通常,与Nginx捆绑在一起,Apache所做的一切都是浪费您的资源。

关于WP Super Cache,如果您创建一个新文件并将其粘贴,它将为您提供这些文件,并且在我们使用它的同时,还可以使用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,有很多知识要知道。 如果您愿意,这对您来说是个不错的开始...

.. 在NGINX上设置WordPress(FURL和缓存)-VPS Bible Pt 13

回覆。 Virtualmin ..我知道您想要一个CP,但事实是,资源成本大于软件成本..再加上用CP进行处理所需的时间更长。

我目前正在发布一个由21个部分组成的VPS Admin系列,坦率地说,该系列解决了缺少Nginx CP的问题。

给定一两个星期,我挑战您告诉我使用CP更快或更有效:)

您可以使用免费的 WordOps - WordPress 站点和服务器管理,它已经为WP Super Cache和其他缓存插件提供了nginx 配置选项 (--wpsc)

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

设置Nginx本身就可以提供php和动态页面,您将获得更快的服务,并且不会出现apache死机并使webserver(Nginx)挂起的问题。

如果您的管理面板不支持此功能,那么您可能首先应该只使用apache。 两者之一都在问问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM