Awstats 是一个非常简洁而且强大的统计工具。它可以统计您站点的如下信息:
一:访问量,访问次数,页面浏览量,点击数,数据流量等精确到每月、每日、每
小时的数据
二:访问者国家、访问者 IP、操作系统、浏览器等
三: Robots/Spiders 的统计
四:纺客持续时间
五:对不同 Files type 的统计信息
六: Pages-URL 的统计
七:其它信息(搜索关键字等等)
http://awstats.sourceforge.net/ awstats 官方网站
http://www.perl.com/ perl 官方网站


环境系统:Centos6

1:Awstats 基于 Perl 的 WEB 日志分析工具所以必须安装perl

https://www.perl.org/get.html#win32        下载perl的linux版本

tar -zxvf  perl-5.24.1.tar.gz

cd perl-5.24.1

sh Configure -de     -----------如果执行不成功很有可能是系统没有安装gcc     yum install gcc

make    编译

make install   安装

安装完成后 perl 所在目录为 /usr/local/lib/perl5, perl 执行文件在 /usr/local/bin 中。

perl -version    查看是否安装成功

This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-linux


Copyright 1987-2017, Larry Wall


Perl may be copied only under the terms of either the Artistic License or the

GNU General Public License, which may be found in the Perl 5 source kit.


Complete documentation for Perl, including FAQ lists, should be found on

this system using "man perl" or "perldoc perl".  If you have access to the

Internet, point your browser at http://www.perl.org/, the Perl Home Page.

提示这个表示安装成功。



2:安装apache服务

yum -y install httpd

rpm -qa httpd    ------查看安装

/etc/init.d/httpd start     开启服务

chkconfig httpd on        开机启动服务

chkconfig --list httpd      查看服务状态

3:安装配置awstats

创建的两个目录都将在后面的配置中用到,一个用于存放站点日志分析的配置文件,
一个用于存放日志数据信息

mkdir /etc/awstats

mkdir /var/lib/awstats

cd /usr/local/src/

wget http://jaist.dl.sourceforge.net/project/awstats/AWStats/7.2/awstats-7.2.tar.gz     ------下载源码安装包

tar xf awstats-7.2.tar.gz

cp -R ./awstats-7.2 /usr/local/    ------复制目录及目录内的所有项目到/usr/local/目录下

cd /usr/local/

mv awstats-7.2/ awstats     ---------进行一个重命名,便于操作而已。

配置 awstats

cd /usr/local/awstats/tools               ---------------Awstats 的配置有自带的配置工具 awstats_configure.pl 

[root@localhost tools]# perl awstats_configure.pl
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf                      #
填写 httpd 配置文件的路径
file (required if first install) [y/N] ? y
Your web site, virtual server or profile name:
> web                                                                         #
设置一个网站的域名或名称
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>                                                                                  #
此处回车即可

然后,两个回车配置完成。

修改配置文件中 apache 日志的路径

cd /etc/awstats

vim awstats.web.conf
LogFile="/var/log/httpd/access_log" #
改为 apache 的日志文件

cd /usr/local/awstats/wwwroot/cgi-bin

chmod +x awstats.pl

perl awstats.pl -update -config=web

#出现以下信息则表示成功
Update for config "/etc/awstats/awstats.web.conf"
With data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Jumped lines in file: 0
Parsed lines in file: 0
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 0 new qualified records.


现在将分析的日志放到网站的首页目录
perl awstats.pl -update -config=web -output -staticlinks >/var/www/html/awastats.html


现在打开浏览器进行访问 http://IP/awastats.html
[root@awstats ~]# chown -R apache.apache /var/www/html/ #对站点目录进行授权
[root@awstats ~]# /etc/init.d/httpd restart #重启 httpd 服务