首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Fedora下安装日志分析工具AWStats

Fedora下安装日志分析工具AWStats

作者头像
星哥玩云
发布于 2022-07-03 09:49:49
发布于 2022-07-03 09:49:49
4830
举报
文章被收录于专栏:开源部署开源部署

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

服务器是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文件,默认的是:

代码语言:javascript
复制
<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

代码语言:javascript
复制
#!/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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档