awstats简介

AWStats是一个专门用来分析Web站台记录档(log)的GPL授权软体,Awstats 是在 SourceForge 上发展很快的一个基于 Perl 的 WEB 日志分析工具,一个充分的日志分析让 Awstats 显示您下列资料:

ü 参观者:按来访者不重复的IP统计,一个IP代表一个参观者.

ü 参观次数:一个参观者可能1天之内参观多次(比如:上午一次,下午一次),所以按一定时间内(比如:1个小时) ,不重复的IP数统计,参观者的访问次数.

ü 网页数:不包括图片,CSS, JavaScript文件等的纯页面访问总数,但如果一个页面使用了多个帧,每个帧都算一个页面请求.

ü 文件数:来自浏览器客户端的文件请求总数,包括图片,CSS,JavaScript等,用户请求一个页面是,如果页面中包含图片等,所以对服务器会发出多次文件请求,文件数一般远远大于文件数.

ü 字节:传给客户端的数据总流量.

awstats安装配置

1. 基本安装

[root@localhost opt]# mv awstats-6.7 /usr/local/awstats/ #将awstats放入/usr/local/awstats

[root@localhost opt]# cd /usr/local/awstats/

[root@localhost awstats]# cd tools/

[root@localhost tools]# ./awstats_configure.pl #运行启动安装向导

----- AWStats awstats_configure 1.0 (build 1.7) (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

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):

> /etc/httpd/conf/httpd.conf #输入你httpd.conf的路径,这里将awstats的配置信息直接写入了httpd.conf

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'

AWStats directives already present.

# 根据上面的httpd配置,更新了awstats.model.conf的内容,下面的.conf文件都要根据这个生成。

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

File awstats.model.conf updated.

#下面问你是否要创建一个新的配置文件,选择y,需要创建。

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

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

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

#下面是要生成conf文件的名称了,因为conf文件的名称都是awstats.yourdomainname.conf格式的,所以这里要求你输入你要监测的域名,其实这个域名只是与其他域名相区分的,并不一定非要真实的。我这里输入的是www.test.com

-----> 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:

> www.test.com

下面是让你输入配置文件的路径,直接回车就可以了,当然你也可以自己定义

-----> 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):

> /etc/awstats

-----> Create config file '/etc/awstats/awstats.www.test.com.conf'

Config file /etc/awstats/awstats.www.test.com.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=www.test.com

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...

2. 建立数据存放目录

[root@localhost awstats]# cd awstats #在这个目录建立一个Data文件夹

[root@localhost awstats]# mkdir -m 755 data #设置权限为755,不能被别人修改

3. 修改httpd.conf配置文件

[root@localhost awstats]# cd tools/

[root@localhost tools]# less httpd_conf

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

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

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

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

<Directory "/usr/local/awstats/wwwroot">

Options None

AllowOverride None

Order allow,deny

Allow from all

</Directory>

将以上内容写入/etc/httpd/conf/httpd.conf文件内

4. 修改/etc/awstats下的日志配置文件

[root@localhost tools]# cd /etc/awstats/

[root@localhost awstats] # ls

awstats.www.test.com.conf

[root@localhost awstats] # vi awstats.www.test.com.conf

编辑LogFile为web server的log文件位置 LogFile=/data/access_log

设置所要分析网站域名 SiteDomain="www.test.com"

设置awstats的数据库存放目录 DirData="/usr/local/awstats/data

修改图片位置DirIcons="/awstatsicons"

如果分析IIS日志,即修改:

LogFormat= 2 
LogFormat = "%time2 %method %url %query %logname %host %ua %referer %code %bytesd %other "

5. 生成数据

/usr/local/awstats/wwwroot/cgi-bin /awstats.pl -update -config=www.test.com,因为这个程序是通过分析日志来进行流量统计的,如果你的日志文件很大的话是很耗系统资源的。

6. 访问

http://IP/awstats/awstats.pl?config=www.test.com

7. 安装插件:

安装纯真版 IP 数据库来分析 IP

1) 下载 纯真版 IP 数据库,解压后得到QQWry.Dat。

2) 下载 qqhostinfo.pm。

3) 下载 分析 QQWry.dat 的 perl 脚本,得到 qqwry.pl,打开修改一下,把./QQWry.Dat 修改为 ${DIR}/plugins/QQWry.Dat。我们此处的路径为/usr/local/awstats/wwwroot/cgi-bin/plugins。

4) 把 QQWry.Dat, qqhostinfo.pm, qqwry.pl 放在 /usr/local/awstats/wwwroot/cgi-bin/plugins 下面。

5) 打开awstats.osxcn.com.conf,在 # PLUGINS 部分加上一句 LoadPlugin=”qqhostinfo”。