« 让每个Virtual Terminal都有鼠标 | Main | 网络监测工具zabbix »

Awstats日志分析工具

awstats早已进入FreeBSD ports,通过ports安装非常方便。
#cd /usr/ports/www/awstats
#make
#make install
安装结束提示信息有:

Please add the following to your apache config, and restart.
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icons/"
ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/www/awstats/">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

软件主要文件安装在 /usr/local/www/awstats 目录下。可按照上述提示信息,修改apache的配置文件,并修改apache的log文件格式,在httpd.conf文件中加入:
LogFormat "%h %l %u %t \"%r\" %>s b \"{Referer}i\" \"%{User-Agent}i\"" combined
并修改 CustomLog一行为:
CustomLog /var/log/httpd-access.log combined
重起httpd服务,或使用下面的方法:

这里注意FreeBSD ports安装时在/usr/local/www/awstats/ 目录下创建了6个目录:cgi-bin,classes,css,icons,js和tools,需要创建新目录wwwroot,并把除tools以外的其他五个目录移到wwwroot下。
可使用 tools目录下的awstats_configure.pl脚本创建awstats的配置文件,该脚本可自动检查apache的配置文件并进行适当修改,并创建相应的配置文件,默认存储在/etc/awstats目录下。
需要的时候需要对生成的配置文件进行修改,如修改配置文件中指定的log文件的存储路径等。

配置完成后,可执行 cgi-bin/awstats.pl -config= 来分析你的日志文件,如果执行正确无误的话,可在/etc/crontab中加入:
0 1 * * * root /usr/local/www/awstats/cgi-bin/awstats.pl -update -config=
让该命令每天周期性运行,以保持数据更新。

TrackBack

TrackBack URL for this entry:
http://bsd.starhiway.net/cgi-bin/mt/mt-tb.cgi/146

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)