awstats分析web日志


下载地址:http://nchc.dl.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0.tar.gz


# tar zxf awstats-6.9.tar.gz
# mv awstats-6.9 /usr/local/apache/awstats

# mv /usr/local/apache/htdocs/* /usr/local/apache/awstats/wwwroot            (即把原网站内容放

到/usr/local/apache/awstats/wwwroot下面)
# cd /usr/local/apache/awstats/tools
# perl awstats_configure.pl 
     在[y/N]提示时,输入y
     Your web site, virtual server or profile name: 
     >www.benet.com      回车
     Press ENTER to finish。。。 回车
     Press ENTER to finish。。。 回车

4.配置

# vi /etc/awstats/awstats.www.benet.com.conf
     LogFile="/usr/local/apache/logs/access_log"
     DirData="/usr/local/apache/awstats/data"
     DirCgi="/usr/local/apache/awstats/wwwroot/cgi-bin"

     DirIcons="/usr/local/apache/awstats/wwwroot/icons"
     AllowToUpdateStatsFromBrowser=1

5.设置权限

# chown -R root:root /usr/local/apache/awstats
# chmod -R 755 /usr/local/apache/awstats
# mkdir /usr/local/apache/awstats/data
# chown nobody.nobody  /usr/local/apache/awstats/data
# chmod 777 /usr/local/apache/awstats/data
# chmod 755 /usr/local/apache/awstats/wwwroot/cgi-bin/*.pl

7.修改网站配置文件
  
# vi /usr/local/apache/conf/httpd.conf

    ....

    CustomLog     combinedServerTokens   Full                   (第102行)

    ....

    <VirtualHost 192.168.1.2>
    DocumentRoot   /usr/local/apache/awstats/wwwroot
    ServerName     www.benet.com
    CustomLog      logs/access_log  combined
    </VirtualHost>

    :wq

# /usr/local/apache/bin/apachectl restart
8.生成分析日志与静态查看界面

# cd /usr/local/apache/htdocs/awstats/wwwroot/cgi-bin
# perl awstats.pl -config=www.benet.com -update -lang=cn
# perl awstats.pl -config=www.benet.com -output -staticlinks -lang=cn>awstats.www.benet.html


9.测试  http://www.benet.com/awstats/awstats.pl?config=www.benet.com

 


遇到的问题:

1.perl awstats.pl -config=www.benet.com -update -lang=cn提示出错,或在测试时提示出错。LogFormat不

正确:

    原因:access_logs格式不正确,删除access_logs,重启APACHE。搞定

2.测试时看图片显示不了。

   原因:/etc/awstats/awstats.www.benet.conf中的DirIcons配置不正确,这个目录一定要

从/usr/local/apache/htdocs目录开始算,相对目录,要确保配置的目录可能过http访问到

3.点击测试页面的“立即更新”时,提示"xxxx.tmp"无法存储
 

  原因:/usr/local/awstats/data的权限不正确,需要使用nobody权限,赋777.

 

 

 

awstats中ip的访问控制

 


# vi /usr/local/apache/conf/httpd.conf

<Directory "/usr/local/awstats/wwwroot">
AllowOverride none
Options none
Order allow,deny
Allow from 192.168.0.0/24
Deny from 192.168.0.100
Deny from www.accp.com
</Directory>

 

 

 

awstats中用户的访问控制

 


# vi /usr/local/apache/conf/httpd.conf

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

.....


AuthName "AWSTATS"
AuthType Basic
AuthUserFile /usr/local/awstats/wwwroot/.htpasswd
require valid-user
</Directory>

# cd /usr/local/apache/bin
# ./htpasswd - c /usr/local/awstats/wwwroot/.htpasswd

awuser

密码

# /usr/local/apache/bin/apachectl restart