阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Fedora下安装日志分析工具AWStats

177次阅读
没有评论

共计 2847 个字符,预计需要花费 8 分钟才能阅读完成。

之前用 Google Analytics 分析网站,觉得多一次请求,对用户不太好,于是自己分析统计 apache log。大约花了一个小时安装测试 awstats,比预期的要顺利。

CentOS 6.3 下 AWStats+GeoIP 实现查看网站访问归属地 http://www.linuxidc.com/Linux/2013-06/85984.htm

Nginx 日志分析 AWStats + JAWStats 安装配置 http://www.linuxidc.com/Linux/2013-06/85567.htm

经典日志分析工具 -AWStats http://www.linuxidc.com/Linux/2012-12/77080.htm

AWStats 日志系统配置文件和错误归纳 http://www.linuxidc.com/Linux/2012-12/75657.htm

使用 AWStats 分析网站日志 - 强大的日志分析工具 http://www.linuxidc.com/Linux/2012-11/74431.htm

服务器是 Fedora,用 yum 安装很快。
[root@athena~]# yum install awstats

用默认的安装方法,/etc/httpd/conf.d/ 目录下面已经有了 awstats.conf, 如果没有,复制一个过去
# cp /usr/share/awstats/tools/httpd_conf /etc/httpd/conf.d/awstats.conf

编辑 /etc/httpd/conf.d/awstats.conf 文件,默认的是:

<Directory "/usr/share/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from 127.0.0.1
</Directory>

如果是外面的服务器,将 127.0.0.1 改为 all

[root@athena~]# cp /etc/awstats/awstats.module.conf /etc/awstats/awstats.broncho.cn.conf
编辑 /etc/awstats/awstats.broncho.cn.conf, 修改下面三项即可:
SiteDomain="broncho.cn"
LogFile="/var/log/httpd/broncho.cn_access_log.%YYYY-0%MM-0%DD-0"
Lang="cn"

[root@athena~]# cd /usr/share/awstats/wwwroot/cgi-bin
[root@athena cgi-bin]# ./awstats.pl -update -config=broncho.cn

发现:

Create/Update database for config“/etc/awstats/awstats.broncho.cn.conf”by AWStats version 6.8 (build 1.910)
From data in log file“/var/log/httpd/broncho.cn_access_log.20100927″…
Phase 1 : First bypass old records, searching new record…
Searching new records from beginning of log file…
AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.
Your log file /var/log/httpd/broncho.cn_access_log.20100927 must have a bad format or LogFormat parameter setup does not match this format.
Your AWStats LogFormat parameter is:1
This means each line in your web server log file need to have“combined log format”like this:
111.22.33.44 – – [10/Jan/2001:02:14:14 +0200]“GET / HTTP/1.1″ 200 1234“http://www.fromserver.com/from.htm”“Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)”
And this is an example of records AWStats found in your log file (the record number 50 in your log):
113.227.9.179 – – [27/Sep/2010:10:34:49 +0800]“GET /forum/styles/prosilver_se/theme/images/border_right.gif HTTP/1.1″ 200 124
Setup (‘/etc/awstats/awstats.broncho.cn.conf’file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in‘docs’directory).

原来的日志按天分割的:

CustomLog“|/usr/local/sbin/cronolog /var/log/httpd/broncho.cn_access_log.%Y%m%d”common

按错误提示,修改为:

CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/broncho.cn_access_log.%Y%m%d" combined

浏览 http://192.168.1.222/awstats/awstats.pl?config=broncho.cn 就可以看到效果。

定时分析日志,在服务器负载比较低的时候,一般是凌晨 3,4 点。

[root@athena~]# vim /usr/share/awstats/wwwroot/cgi-bin/awstats.sh

#!/bin/bash

cd /usr/share/awstats/wwwroot/cgi-bin
perl awstats.pl -update -config=broncho.cn

[root@athena~]# chmod 755 /usr/share/awstats/wwwroot/cgi-bin/awstats.sh

[root@athena~]# crontab -e
0 3 * * * /usr/share/awstats/wwwroot/cgi-bin/awstats.sh

AWStats 的详细介绍 :请点这里
AWStats 的下载地址 :请点这里

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计2847字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中