设置静态地址
设置WordPress静态化URL链接有助于被搜索引擎收入
在wordpress中选择仪表盘,设置,固定链接,然后再点击自定义结构,填入/%post_id%.html。
这个时候如果再点击之前的文字,可能会出现404的错误,需要在nginx配置文件里面添加3个if,下列代码是添加后的效果
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
插件WP Super Cache
安装WP Super Cache存静态插件,让服务器获得更多的并发。
启用PHP的Opcache缓存功能
有了WP Super Cache这样的插件后,还可以启用PHP的Opcache缓存功能和Memcached、Redis等内存缓存功能。因为使用缓存功能还可以压榨一些服务器的性能,让服务器更好的分配好资源使用。