wordpress,Lnmp安装ngx_cache_purge缓存模块

本文共有3685个字。 # wordpress/ a

1、配置文件

配置lnmp.conf 文件,在Nginx_Modules_Options里面添加--add-module=/root/ngx_cache_purge-2.3

Nginx_Modules_Options='--add-module=/root/ngx_cache_purge-2.3'

2、升级nginx,进入到lnmp文件包目录

./upgrade.sh nginx

升级完毕后执行 nginx -V 查看是否安装成功

3、配置虚拟主机,在vhost/xx.conf

fastcgi_cache_path /tmp/nginx-cache levels=1:2 keys_zone=WORDPRESS:192m inactive=1d;
fastcgi_temp_path /tmp/nginx-cache/temp;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

server
    {
        listen 80;
        #listen [::]:80;
        server_name muai8.com www.muai8.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/muai8.com;

        include rewrite/wordpress.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        #include enable-php-pathinfo.conf;

        set $skip_cache 0;
          # POST 和带参数的请求不展示缓存
          if ($request_method = POST) {
              set $skip_cache 1;
          }
          if ($query_string != "") {
              set $skip_cache 1;
          }   
          # 指定页面不展示缓存
          if ($request_uri ~* "/wp-admin/|/go/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
            set $skip_cache 1;
          }   
          # 登录用户和评论过的用户不展示缓存
           if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
               set $skip_cache 1;
           }
          
          location ~ [^/]\.php(/|$) {
            #fastcgi_pass remote_php_ip:9000;
            fastcgi_pass unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_cache_bypass $skip_cache;
            fastcgi_no_cache $skip_cache;
            add_header X-Cache "$upstream_cache_status From $host";
            fastcgi_cache WORDPRESS;
            fastcgi_cache_valid  200 301 302 1d;
          }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            #expires      30d;
            access_log  off;
            log_not_found off;
            expires   max;
        }

        location ~ .*\.(js|css)?$
        {
            expires      7d;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }

参考资料

Nginx开启fastcgi_cache缓存加速,支持html伪静态页面

Nginx 启用 FastCGI_Cache 将 WordPress 静态化缓存加速

WordPress开启Nginx fastcgi_cache缓存加速方法-Nginx配置实例

网站速度飞起来: WordPress插件W3 Total Cache教程

利用W3 Total Cache配置Memcached和Redis缓存 优化加速WP速度

我正在用的WordPress插件-WP SEO,CDN,缓存,图片,邮件,论坛插件

WordPress开启Nginx fastcgi_cache缓存加速方法-Nginx配置实例

Linux的php-fpm优化心得-php-fpm进程占用内存大和不释放内存问题

fastcgi_cache with conditional purging

版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。本站微信公众号:7TEC,敬请关注!

添加新评论

暂无评论