AWStats 是一个免费的强大而有个性的工具,带来先进的网络,流量,FTP或邮件服务器统计图. 它能分析日志文件来自从各大服务器工具 ,如 Apache日志档案  (NCSA combined or common),  IIS (W3C),Proxy、Wap、流量服务器、邮件服务器和一些FTP服务器等等。
   注:
  1:需要系统正常运行perl环境。
  2:apache运行正常。
1:到官方网站下载最新版本,目前的版本是 Awstats 6.9
下载后上传到主机上进行安装和配置。
2:其实awstats安装是非常容易的,大致的步骤如下:
[root@centos opt]#tar zxvf awstats-6.6.tar.gz
[root@centos opt]# cd awstats-6.6
[root@centos awstats-6.6]# cd tools/
[root@centos tools]# perl awstats_configure.pl
Do you want to continue setup from this NON standard directory [yN] ? y   

//输入你的web server的配置文件路径 使用none跳过设置
Config file path ('none' to skip web server setup):     
> none

Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

Your web site, virtual server or profile name:
> [url]http://www.test.net/[/url]
直接回车 使用默认路径 /etc/awstats
Directory path to store config file(s) (Enter for default):      
> /etc/awstats
再次敲回车,到此为止awstats安装完成,(是不是觉得太简单了啊!)接下来配置awstats:
A:[root@centos /]# cd /etc/awstats/ (这个目录是存放awstats配置文件的)
[root@centos awstats]# vi awstats.[url]www.test.net.conf[/url]
#LogFile="/var/log/httpd/mylog.log"
LogFile="/usr/local/apache2/logs/access_log" (修改你要分析的日志文件的路径)
//日志分析结果输出目录 确保该目录有写权限
    DirData="/var/www/awstats/test/dirdata"
//指定日志格式 1 - Apache combined logs  2 - IIS
    LogFormat=1   (如果是分析apache 可以用默认的,如果是分析IIS就应该选2)
  AllowToUpdateStatsFromBrowser=1 允许查看的时候进行更新日志数据
:wq   保存退出。
B: 运行:perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net
如果是第一次运行更新的话,awstats会出现错误:AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log。其实从错误信息中不难看出原因,解决办法就是把用分析的日志文件删除,重新加载即可。
为了让系统自动作业,把命令加入系统的crontab,
[root@centos awstats]# crontab -e
30 23 * * * root perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net (每天晚上11:30进行日志分析)
访问权限配置
有时候网站的日志信息不想给竞争对手看到,所以需要对日志查看进行授权,授权方式如下:
编辑apache的配置文件 vi /usr/local/apache2/conf/httpd.conf
<Directory "/opt/awstats-6.6/wwwroot">
    Options None
   # AllowOverride None
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /usr/local/apache2/conf/passwords
    Require user dbasky
</Directory>
利用apapche的htpasswd生成个系统的用户,达到系统的加密:
/usr/local/apache2/bin/htpasswd -c /usr/local/apache2/conf/passwords admin
此时输入二次密码确认密码.
配置完成后,重启apapche,ok!awstats就配置完成了,可以看看我们的成果了: