1、 安装awstats。
(1) 下载awstats
(2) 解压wget http://downloads.sourceforge.net/awstats/awstats-6.7.tar.gz?modtime=1183813789&
big_mirror=0
awstats需要apache协同工作,请自行安装之。Apache安装好以后,运行命令/usr/local/apache/bin/httpd –l | grep mod_cgi.c 看是否把模块编译进来,这个模块是必须的。接着再检查perl工具是否被安装到系统,如果没有安装,请手动安装。tar xvf wstats-6.7.tar.gz
mv awstats-6.7 /usr/local/awstats
2、 配置awstats。
执行配置脚本,这是一个交互程序,可根据自己的实际情况回答cd /usr/local/awstats/tools
执行完配置后,将生成配置文件/etc/aswstats/ awstats.sery.conf,修改perl 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
Found Web server Apache config file '/usr/local/apache2/conf/httpd.conf'
![]()
-----> Check and complete web server config file '/usr/local/apache2/conf/httpd.conf'
![]()
-----> 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 ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?
然后再执行 perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=sery.com –update 如果没有错误的话,在浏览器输入awstats服务器的ip地址即可得到访问日志报告。我们不想无关的人看见日志报告,用apache用户验证功能来完成,把下面的内容加入到apache配置文件httpd.conf即可:LogFile=/root/logs/awstats_log/17k.com-access.log
把awstats更新加入 crontab,让它每天自动执行一次。lias /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/cgi-bin/">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "17k awstats Access"
AuthUserFile /usr/local/awstats/.htpasswd
Require valid-user
</Directory>
每天早上6点会自动执行一次更新操作,对日志文件进行处理,最后在浏览器里读出所需数据。crontab –e
00 06 * * * /usr/local/bin/awstats_update.sh
脚本/usr/local/bin/awstats_update的内容:
#!/bin/bash
perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=17k.com -update >> /usr/local/awstats/awstats_update.log

