wordpress优化记录

seofangfa wordpress学习评论145阅读模式

1、系统环境:CentOS6.8 64位+lnmp1.4,VPS配置不高的话(1G内存以内)直接默认安装LNMP就行,配置高的话php/mysql都选最新版本

2、如果主题支持PHP7的话,一定要安装PHP7,速度提升明显

3、安装两个PHP扩展,Opcache(PHP缓存)、Redis(数据库缓存)

4、调整php-fpm,参考https://seofangfa.com/other-note/php-fpm.html

5、不必要的插件全禁用,必备的有Redis Object Cache、WP Super Cache

6、给页面加上系统消耗信息显示,直观看优化效果

下面这个是放到functions.php

//显示页面查询次数、加载时间和内存占用
function performance( $visible = false ) 
{
	$stat = sprintf(  '%d queries in %.3f seconds, using %.2fMB memory',
		get_num_queries(),
		timer_stop( 0, 3 ),
		memory_get_peak_usage() / 1024 / 1024
	);
	echo $visible ? $stat : "<!-- {$stat} -->" ;
}

下面这个放到footer.php的</html>之后

<?php if(function_exists('performance')) performance(true) ;?>

文章末尾固定信息

weinxin
我的微信
我的微信
微信扫一扫
 
seofangfa
  • 本文由 seofangfa 发表于 2017年6月22日17:50:05
  • 转载请务必保留本文链接:https://wp.fangfa.me/wordpress-study/wordpress-youhua.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证