全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2831|回复: 13
打印 上一主题 下一主题

[疑问] 设置了wp super cache的rewrite规则之后,nginx提示错误

[复制链接]
跳转到指定楼层
1#
发表于 2010-5-5 19:09:00 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
装的是顶置的lnmp0.4

重启lnmp的时候,提示:
  1. Reload LNMP...
  2. Reload Nginx configure...
  3. [emerg]: "expires" directive is not allowed here in /usr/local/nginx/conf/wordpress_params_supercache.conf:3
  4. configuration file /usr/local/nginx/conf/nginx.conf test failed
  5. Nginx program is reloding!
  6. Shutting down MySQL. SUCCESS!
  7. Starting MySQL. SUCCESS!
  8. Shutting down php_fpm . done
  9. Starting php_fpm  done
复制代码
nginx.conf中引用了wordpress_params_supercache.conf文件,如下所示:
  1. server
  2.         {
  3.                 listen    80;
  4.                 server_name www.xxx.com xxx.com;
  5.                 index index.html index.htm index.php;
  6.                 root  /home/wwwroot;
  7.                
  8.                     include wordpress.conf;
  9.                 include wordpress_params_supercache.conf;
复制代码
这是wordpress_params_supercache.conf文件的内容:
  1. # if the requested file exists, return it immediately
  2. if (-f $request_filename) {
  3. expires 30d;
  4. break;
  5. }

  6. set $supercache_file '';
  7. set $supercache_uri $request_uri;

  8. if ($request_method = POST) {
  9. set $supercache_uri '';
  10. }

  11. # Using pretty permalinks, so bypass the cache for any query string
  12. if ($query_string) {
  13. set $supercache_uri '';
  14. }

  15. if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
  16. set $supercache_uri '';
  17. }

  18. # if we haven't bypassed the cache, specify our supercache file
  19. if ($supercache_uri ~ ^(.+)$) {
  20. set $supercache_file /home/wwwroot/wp-content/cache/supercache/$http_host/$1index.html;
  21. }

  22. # only rewrite to the supercache file if it actually exists
  23. if (-f $document_root$supercache_file) {
  24. rewrite ^(.*)$ $supercache_file break;
  25. }

  26. # all other requests go to Wordpress
  27. if (!-e $request_filename) {
  28. rewrite . /home/wwwroot/index.php last;
  29. }
复制代码
14#
 楼主| 发表于 2010-5-7 12:56:36 | 只看该作者
原帖由 fish 于 2010-5-7 12:24 发表
不要紧


那就好,谢谢啦~~
13#
发表于 2010-5-7 12:24:22 | 只看该作者

回复 12# 的帖子

不要紧
12#
 楼主| 发表于 2010-5-7 12:16:16 | 只看该作者
原帖由 fish 于 2010-5-6 22:08 发表

我的,肯定对,正在用呢


用了你这个确实可以

但是下面这些,原来自带的这些rewrite规则不用要不要紧呢?
  1. if (-f $request_filename/index.html){
  2.                 rewrite (.*) $1/index.html break;
  3.         }
  4. if (-f $request_filename/index.php){
  5.                 rewrite (.*) $1/index.php;
  6.         }
  7. if (!-f $request_filename){
  8.                 rewrite (.*) /index.php;
  9.         }
复制代码
11#
发表于 2010-5-6 22:08:32 | 只看该作者
                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
                {
                        expires 30d;
                }
                location /
                {
                        autoindex off;
                        set $wp_super_cache_file '';
                        set $wp_super_cache_uri $request_uri;
                        if ( $request_method = POST )
                        {
                                set $wp_super_cache_uri '';
                        }
                        if ( $query_string )
                        {
                                set $wp_super_cache_uri '';
                        }
                        if ( $http_cookie ~* "comment_author_|WordPress|wp-postpass_" )
                        {
                                set $wp_super_cache_uri '';
                        }
                        if ( $wp_super_cache_uri ~ ^(.+)$ )
                        {
                                set $wp_super_cache_file /wp-content/cache/supercache/$http_host/$1index.html;
                        }
                        if ( -f $document_root$wp_super_cache_file )
                        {
                                rewrite ^(.*)$ $wp_super_cache_file break;
                        }
                        if (-f $request_filename)
                        {
                                expires 30d;
                                break;
                        }
                        if (!-e $request_filename)
                        {
                                rewrite ^(.+)$ /index.php last;
                        }
                }

我的,肯定对,正在用呢

评分

参与人数 1威望 +5 收起 理由
GoTop + 5 多谢

查看全部评分

10#
发表于 2010-5-6 21:13:16 | 只看该作者
type的飘过~
9#
发表于 2010-5-6 20:19:21 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
8#
发表于 2010-5-6 19:59:10 | 只看该作者
只会lighttpd 的飘过
7#
 楼主| 发表于 2010-5-6 18:27:17 | 只看该作者
原帖由 greensnow 于 2010-5-5 19:51 发表
php文件停止解析了,你肯定配置写错了


不知道哪里错了

我直接不要这些规则了

网站能访问

貌似对wp super cache 也没什么影响啊
6#
发表于 2010-5-5 19:51:33 | 只看该作者
php文件停止解析了,你肯定配置写错了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-11 16:54 , Processed in 0.117179 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表