您的位置:首页 > 理论基础 > 计算机网络

http日志分析工具awstat安装详解

2011-09-10 22:05 381 查看
http日志分析工具awstat安装详解

awstat的功能:

  AWStats是在Sourceforge上发展很快的一个基于Perl的WEB日志分析工具。它可以统计您站点的如下信息:

  一:访问量,访问次数,页面浏览量,点击数,数据流量等

  二:精确到每月、每日、每小时的数据

  三:访问者国家

  四:访问者IP

  五:Robots/Spiders的统计

  六:纺客持续时间

  七:对不同Files type 的统计信息

  八:Pages-URL的统计

  九:访客操作系统浏览器等信息

  十:其它信息(搜索关键字等等)

安装:

awstats-7.0.zip下载地址:
http://sourceforge.net/projects/awstats/files/AWStats/7.0/awstats-7.0.zip/download
安装之前首先启动apache,并查看进程

/usr/local/apache/bin/apachectl start

解压包:

unzip awstats-7.0.zip

创建存放目录

mkdir -p /usr/local/awstats

mv awstats-7.0/* /usr/local/awstats

确定系统已经安装perl

whereis perl

perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz

编译awstats:

cd /usr/local/awstats/tools

perl awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur -----

This tool will help you to configure AWStats to analyze statistics for

one web server. You can try to use it to let it do all that is possible

in AWStats setup, however following the step by step manual setup

documentation (docs/index.html) is often a better idea. Above all if:

- You are not an administrator user,

- You want to analyze downloaded log files without web server,

- You want to analyze mail or ftp log files instead of web log files,

- You need to analyze load balanced servers log files,

- You want to 'understand' all possible ways to use AWStats...

Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

#如果系统中没有安装apache的话会提示要求你输入apache配置文件的路径

Enter full config file path of your Web server.

Example: /etc/httpd/httpd.conf

Example: /usr/local/apache2/conf/httpd.conf

Example: c:\Program files\apache group\apache\conf\httpd.conf

Config file path ('none' to skip web server setup):

>

#如果系统已安装apache的话,自动会检测到配置文件

-----> Check for web server install

Found Web server Apache config file '/usr/local/apache/conf/httpd.conf'

-----> Check and complete web server config file '/usr/local/apache/conf/httpd.conf'

Warning: You Apache config file contains directives to write 'common' log files

This means that some features can't work (os, browsers and keywords detection).

#输入y,将日志记录方式由'command'改为更详细的‘combined’

Do you want me to setup Apache to write 'combined' log files [y/N] ? y

Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'

Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'

Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'

Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'

Add '<Directory>' directive

AWStats directives added to Apache config file.

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'

File awstats.model.conf updated.

-----> Need to create a new config file ?

#输入y创建一个新的配置文件

Do you want me to build a new AWStats config/profile

file (required if first install) [y/N] ? y

-----> Define config file name to create

What is the name of your web site or profile analysis ?

Example: www.mysite.com

Example: demo

Your web site, virtual server or profile name:

#输入配置文件的名字

> AnalyzeApacheLog

-----> Define config file path

In which directory do you plan to store your config file(s) ?

Default: /etc/awstats

Directory path to store config file(s) (Enter for default):

#指定配置文件目录,一般都是默认的,直接回车就行

>

-----> Create config file '/etc/awstats/awstats.AnalyzeApacheLog.conf'

Config file /etc/awstats/awstats.AnalyzeApacheLog.conf created.

-----> Add update process inside a scheduler

Sorry, configure.pl does not support automatic add to cron yet.

You can do it manually by adding the following command to your cron:

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=AnalyzeApacheLog

Or if you have several config files and prefer having only one command:

/usr/local/awstats/tools/awstats_updateall.pl now

Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/awstats.AnalyzeApacheLog.conf

You should have a look inside to check and change manually main parameters.

You can then manually update your statistics for 'AnalyzeApacheLog' with command:

> perl awstats.pl -update -config=AnalyzeApacheLog

You can also read your statistics for 'AnalyzeApacheLog' with URL:

#查看分析报告的链接如下:

> http://localhost/awstats/awstats.pl?config=AnalyzeApacheLog
Press ENTER to finish...

修改配置文件:

vi /etc/awstats/awstats.AnalyzeApacheLog.conf

#LogFile="/var/log/httpd/mylog.log"

LogFile="/home/wwwlog/www.pcstars.com_access.log"

注:

(1)如果同时分析多个日志

LogFile="/opt/awstats/tools/logresolvemerge.pl /var/apachelogs/30.0206.vblog.log /var/apachelogs/31.0206.vblog.log|"



LogFile="/opt/awstats/tools/logresolvemerge.pl /var/apachelogs/*.0206.vblog.log|"

(2)分析使用gzip压缩过的日志文件

LogFile="gzip -d </var/log/apache/access.log.gz|"

最后重启apache,通过web访问 http://IP/awstats/awstats.pl?config=AnalyzeApacheLo
前提条件是apache对应的端口没有防火墙限制或者SELinux的限制,否则可能会报403错误

如果出现这种情况最好找系统管理员解决,不要擅自修改系统文件

最后千万不要忘了,将下列行加入执行计划:

/usr/local/awstats/tools/awstats_updateall.pl now

或者

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=AnalyzeApacheLog
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐