全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2829|回复: 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. }
复制代码
2#
发表于 2010-5-5 19:10:27 | 只看该作者
expires 30d;去掉
3#
发表于 2010-5-5 19:11:34 | 只看该作者
我的安装包里面的wp super cache的rewrite规则是
        location /
        {
                autoindex off;
                gzip_static on;

                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/wp_super_cache/$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?q=$1 last;
                }
        }

评分

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

查看全部评分

4#
 楼主| 发表于 2010-5-5 19:13:32 | 只看该作者
原帖由 ABC 于 2010-5-5 19:10 发表
expires 30d;去掉


晕,我刚才搜索expires 这个单词的时候没搜到,估计是向下查找了,忘记试试向上查找了.

expires 30d;是什么意思呢
5#
 楼主| 发表于 2010-5-5 19:19:45 | 只看该作者
原帖由 shinko 于 2010-5-5 19:11 发表
我的安装包里面的wp super cache的rewrite规则是
        location /
        {
                autoindex off;
                gzip_static on;

                set $wp_super_cache_file '';
                ...


谢谢,我把wp super cache的rewrite规则放到location /{}里面就正常了~~~

但是网站打开的时候不显示网页了
显示这样的文字:
  1. <?php
  2. /**
  3. * Front to the WordPress application. This file doesn't do anything, but loads
  4. * wp-blog-header.php which does and tells WordPress to load the theme.
  5. *
  6. * @package WordPress
  7. */

  8. /**
  9. * Tells WordPress to load the WordPress theme and output it.
  10. *
  11. * @var bool
  12. */
  13. define('WP_USE_THEMES', true);

  14. /** Loads the WordPress Environment and Template */
  15. require('./wp-blog-header.php');
  16. ?>
复制代码

[ 本帖最后由 GoTop 于 2010-5-5 19:25 编辑 ]
6#
发表于 2010-5-5 19:51:33 | 只看该作者
php文件停止解析了,你肯定配置写错了
7#
 楼主| 发表于 2010-5-6 18:27:17 | 只看该作者
原帖由 greensnow 于 2010-5-5 19:51 发表
php文件停止解析了,你肯定配置写错了


不知道哪里错了

我直接不要这些规则了

网站能访问

貌似对wp super cache 也没什么影响啊
8#
发表于 2010-5-6 19:59:10 | 只看该作者
只会lighttpd 的飘过
9#
发表于 2010-5-6 20:19:21 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
10#
发表于 2010-5-6 21:13:16 | 只看该作者
type的飘过~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-11-11 09:34 , Processed in 0.074707 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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