全球主机交流论坛

标题: 设置了wp super cache的rewrite规则之后,nginx提示错误 [打印本页]

作者: GoTop    时间: 2010-5-5 19:09
标题: 设置了wp super cache的rewrite规则之后,nginx提示错误
装的是顶置的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. }
复制代码

作者: ABC    时间: 2010-5-5 19:10
expires 30d;去掉
作者: shinko    时间: 2010-5-5 19:11
我的安装包里面的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;
                }
        }
作者: GoTop    时间: 2010-5-5 19:13
原帖由 ABC 于 2010-5-5 19:10 发表
expires 30d;去掉


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

expires 30d;是什么意思呢
作者: GoTop    时间: 2010-5-5 19:19
原帖由 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 编辑 ]
作者: greensnow    时间: 2010-5-5 19:51
php文件停止解析了,你肯定配置写错了
作者: GoTop    时间: 2010-5-6 18:27
原帖由 greensnow 于 2010-5-5 19:51 发表
php文件停止解析了,你肯定配置写错了


不知道哪里错了

我直接不要这些规则了

网站能访问

貌似对wp super cache 也没什么影响啊
作者: ebizhost    时间: 2010-5-6 19:59
只会lighttpd 的飘过
作者: youland    时间: 2010-5-6 20:19
提示: 作者被禁止或删除 内容自动屏蔽
作者: afterx    时间: 2010-5-6 21:13
type的飘过~
作者: fish    时间: 2010-5-6 22:08
                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;
                        }
                }

我的,肯定对,正在用呢
作者: GoTop    时间: 2010-5-7 12: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.         }
复制代码

作者: fish    时间: 2010-5-7 12:24
标题: 回复 12# 的帖子
不要紧
作者: GoTop    时间: 2010-5-7 12:56
原帖由 fish 于 2010-5-7 12:24 发表
不要紧


那就好,谢谢啦~~




欢迎光临 全球主机交流论坛 (https://lilynana.eu.org/) Powered by Discuz! X3.4