五、配置awstats生成静态页面
利用awstats的工具将统计的结果生成静态文件:
shell# mkdir -p /var/www/awstats
shell# /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=yourwebsite -lang=cn -dir=/var/www/awstats -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
注意:-config=后面的参数是你在执行awstats_configure.pl时输入的站点域名;-dir=是统计结果静态文件的输出目录。
设置crontab,每天凌晨00:01定时更新静态页面:
1 0 * * * /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=yourwebsite -lang=cn -dir=/var/www/awstats -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
一般站长都不愿随便让人知道自己站的真实流量,所以要把awstats统计结果页面进行密码保护,这里需要用到apache自带的工具htpasswd:
shell# yum -y install httpd-tools
shell# htpasswd -cd admin.pass admin
New password:
Re-type new password:
Adding password for user admin
把生成的密码文件admin.pass放到nginx主配置目录下(/etc/nginx/)。
在nginx配置扩展目录(/etc/nginx/conf.d/)下新建awstats.conf配置文件,内容如下:
server {
listen 83;
server_name localhost;
location ~ ^/awstats/ { # html 静态页面目录
root /var/www;
index index.html;
access_log off;
error_log off;
charset gb2312;
auth_basic "admin";
auth_basic_user_file admin.pass;
}
location ~ ^/icon/ { # 图标目录
root /usr/local/awstats/wwwroot;
index index.html;
access_log off;
error_log off;
}
}
最后使nginx重读配置文件,用浏览器查看统计结果 http://yourhostname:83/awstats/awstats.yourwebsite.html
日志分析页面示例:

AWStats 的详细介绍:请点这里
AWStats 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-10/108362.htm
