1.本教程基于宝塔面板(aapanel),如果你不知道什么是宝塔面板(aapanel),请立即关闭本教程;如果你是手搓党,请自行研究安装方法。 2.本教程默认你已经安装好了宝塔面板、LNMP环境以及wordpress程序(不适用于apache)。 3.本教程原理:使用WP Super Cache将php动态页面生成静态html文件以降低服务器负载,加快页面打开速度;使用redis缓存数据库常用数据,减少数据库查询。
1.安装redis
过程不再赘述。
2.安装php的redis和opcache扩展
3.安装wordpress的Redis Object Cache和WP Super Cache缓存插件
# WP Super Cache rules. # Designed to be included from a 'wordpress-ms-...' configuration file. set $cache_uri $request_uri; # 请求方式为post时不使用缓存 if ($request_method = POST) { set $cache_uri 'null cache'; } if ($query_string != "") { set $cache_uri 'null cache'; } # uri包含以下内容时不使用缓存 if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $cache_uri 'null cache'; } # 对登录用户或已发布评论用户不使用缓存 if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { set $cache_uri 'null cache'; }