服务器的内存8G,CPU为4核,宽带8M的阿里云 windows server 2012 、 apache 2.四、php 5.3 、mysql 5.5php
每次打开网站都以为有点慢,用谷歌浏览器查看网页加载时间都在1秒以上。mysql
查找缘由sql
在init.php文件在数据库
$start_time = microtime(true); //放在不一样的位置,查看最后输出的时间差定位耗时位置apache
echo microtime(true) - $start_time;exit; //放在文件最后windows
最后定位出浏览器
if (!defined('INIT_NO_USERS'))
{
/* 初始化session */
include(ROOT_PATH . 'includes/cls_session.php');服务器
$sess = new cls_session($db, $ecs->table('sessions'), $ecs->table('sessions_data'));session
define('SESS_ID', $sess->get_session_id());
}ide
这里的链接数据库耗时将近1秒
解决方法以下:
把文件data/config.php中的
// database host
$db_host = "localhost:3306";
改成
// database host
$db_host = "127.0.0.1:3306";
再来测试
用时157ms
ecshop打开时间慢的问题完美解决