1、nginx
安装目录:/usr/local/nginx
服务目录:/web/html/log/awstats/wwwroot/
 
2、awstats
tar -xzf awstats-6.95.tar.gz
cp -af awstats-6.95/ /web/html/log/awstats
mkdir –m 755 /web/html/log/awstats/data
cd /web/html/log/awstats/tools/
./awstats_configure.pl 

#输入"y",开始配置


#这里用nginx,所以写"none"跳过,如果使用apache,写上apache的配置文件的路径
 

#是否需要创建一个新的配置文件,选择"y"


#查看统计信息的域名或者地址
 

#输入回车,使用默认的路径


#配置向导结束之后,已经创建了awstats的配置文件,可以根据实际的需要修改配置文件里面的内容
 
3、显示地区插件qqhostinfo
tar –xzf awstats_qqhostinfo.tar.gz
cd awstats_qqhostinfo
cp * /web/html/log/awstats/wwwroot/cgi-bin/plugins/
cd /web/html/log/awstats/wwwroot/cgi-bin/plugins/
chmod +x qq*
修改qqhostinfo.pm文件
push @INC, "/web/html/log/awstats/wwwroot/cgi-bin/plugins";
require "/web/html/log/awstats/wwwroot/cgi-bin/plugins/qqwry.pl";
修改qqwry.pl文件
my $ipfile="/web/html/log/awstats/wwwroot/cgi-bin/plugins/QQWry.Dat";
#几个qq*文件的DIR,是根据实际旋转的目录配置的
 
4、配置awstats
vi /etc/awstats/awstats.115.236.59.71.conf
LogFile="/web/html/log/varnish_%YYYY-24%MM-24%DD-24.log"
#指定需要分析的日志文件的位置,%YYYY-24%MM-24%DD-24,表示分析的是前一天的日志
LogType=W
#指定日志分析的类型,W为web日志的文件类型
LogFormat=1
#日志文件格式,1表示采用apache的格式
DirData="/web/html/log/awstats/data"
#awstats更新分析数据时,用来保存分析结果的文件
DirIcons="/awstatsicons"
#awstats图标文件的目录,默认目录是/icon,可以直接修改配置文件DirIcons,也可以做个软链ln –s icon awstatsicons,或者直接复制一个新的目录出来
LoadPlugin="qqhostinfo"
#使用的显示地址的插件,上面我们用到的是qqhostinfo,也可以用其他
 
5、日志切割脚本
vi cutlog.sh
#!/bin/bash
#cutting varnish log,and create new analyse html
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH
 
ROOT=/web/html/log
TS=$(date -d "yesterday" +%Y%m%d)
cd $ROOT
cp varnish.log varnish_$TS.log
echo > varnish.log
/web/html/log/awstats/wwwroot/cgi-bin/awstats.pl -config=115.236.59.71
-lang=cn -update -output > /web/html/log/awstats/wwwroot/index.html
 
6、启用
#nginx
/etc/init.d/nginxd start
#awstats
/web/html/log/awstats/wwwroot/cgi-bin/awstats.pl -config=115.236.59.71 -lang=cn -update -output > /web/html/log/awstats/wwwroot/index.html
 
7、访问