使用AWStats分析网站日志-强大的日志分析工具

wucong0 2012-11-19

运营需要网站的数据统计,本来想用JS的方式来统计所有请求的情况,但是由于时间紧迫,所以重新部署awstats这个工具!
 
AWStats是一个基于Perl的WEB日志分析工具,主页:http://awstats.sourceforge.net
 
Awstats 是一个免费非常简洁而且强大有个性的统计工具。它可以统计您站点的如下信息:
 ① 访问量,访问次数,页面浏览量,点击数,数据流量等
 ② 精确到每月、每日、每小时的数据
 ③ 访问者国家
 ④ 访问者 IP
 ⑤ Robots/Spiders 的统计
 ⑥ 纺客持续时间
 ⑦ 对不同 Files type 的统计信息
 ⑧ Pages-URL 的统计
 ⑨ 访客操作系统浏览器等信息
 其它信息(搜索关键字等等)
 
AWStats 是一个免费的强大而有个性的工具,带来先进的网络流量,FTP 或邮件服务器统计图。 本日志分析器作为 CGI 或从命令行在数个图形网页中显示你日志中包含的所有可能信息。 它利用一部分档案资料就能经常很快地处理大量日志档案,它能分析日志文件来自从各大服务器工具,如 Apache日志档案(NCSA combined/XLF/ELF log format or common/CLF log format), WebStar,IIS (W3C的日志格式)及许多其他网站,Proxy(代理服务器)、Wap、流量服务器、邮件服务器和一些 FTP 服务器。
 
AWStats的运行模式
 
1、统计分析日志:将结果保存在一个txt文件中,最新版本支持xml数据格式。
 
2、输出分析结果:利用cgi程序输出,或生成静态html文件进行浏览。
 
AWStats的安装与配置
 
先创建如下两个目录:
 
/etc/awstats -- 网站统计的配置文件存放位置
 
/var/lib/awstats -- 网站统计的数据文件
 
awstats默认的目录是/usr/local/,所以下载下来请保存至此。
 
awstats采用perl来进行安装,所以服务器一定要有perl环境 yum install perl ;

  1. cd /usr/local;
  2. wget http://prdownloads.sourceforge.net/awstats/awstats-7.0.tar.gz
  3. tar zxvf awstats-7.0.tar.gz;
  4. mv awstats-7.0 awstats;
  5. chown apache:apache awstats -R #设置web服务能访问此目录
  6. perl /usr/local/awstats/tools/awstats_configure.pl #执行awstats安装

安装过程如下:

  1. ----- AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur -----
  2. This tool will help you to configure AWStats to analyze statistics for
  3. one web server. You can try to use it to let it do all that is possible
  4. in AWStats setup, however following the step by step manual setup
  5. documentation (docs/index.html) is often a better idea. Above all if:
  6. - You are not an administrator user,
  7. - You want to analyze downloaded log files without web server,
  8. - You want to analyze mail or ftp log files instead of web log files,
  9. - You need to analyze load balanced servers log files,
  10. - You want to 'understand' all possible ways to use AWStats...
  11. Read the AWStats documentation (docs/index.html).
  12. -----> Running OS detected: Linux, BSD or Unix
  13. Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
  14. If you want to use standard directory, you should first move all content
  15. of AWStats distribution from current directory:
  16. /root
  17. to standard directory:
  18. /usr/local/awstats
  19. And then, run configure.pl from this location.
  20. Do you want to continue setup from this NON standard directory [yN] ?
  21. #这个选项告知你awstats默认应该安装在/usr/local/awstats下,问你是否采用默认的目录,默认即可
  22. -----> Check for web server install
  23. Enter full config file path of your Web server.
  24. Example: /etc/httpd/httpd.conf
  25. Example: /usr/local/apache2/conf/httpd.conf
  26. Example: c:\Program files\apache group\apache\conf\httpd.conf
  27. Config file path ('none' to skip web server setup):
  28. >
  29. #这个选项是问你的apache默认配置文件在哪,awstats会在你的配置文件中增加相关配置选项。
  30. 如果你用Nginx等其他web 跳过此选项,我的配置是: /etc/httpd/conf/httpd.conf
  31. -----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
  32. Add '<Directory>' directive
  33. AWStats directives added to Apache config file.
  34. -----> Need to create a new config file ?
  35. Do you want me to build a new AWStats config/profile
  36. file (required if first install) [y/N] ? 这个选项是询问是否要要生成独立的 conf 文件的名称,
  37. 因为 conf 文件的名称都是 awstats.yourdomainname.conf 格式的,所以这里要求你输入你要监测的域名,
  38. 其实这个域名只是与其他域名相区分的,并不一定非要真实的。
  39. -----> 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/下

  40. -----> Create config file '/etc/awstats/awstats.www.linuxidc.com.conf'
    Config file /etc/awstats/awstats.www.linuxidc.com.conf created.

  41. -----> Create config file '/etc/awstats/awstats.www.linuxidc.com.conf'
    Config file /etc/awstats/awstats.www.linuxidc.com.conf created.

    -----> Restart Web server with '/sbin/service httpd restart'
    Stopping httpd: [ OK ]
    Starting httpd: [ OK ]
  42. -----> 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.linuxidc.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...
  43. #上面是告知你你可以在crontab中单独增加

    01.问题1:Error: Failed to open '/root/wwwroot/cgi-bin/awstats.model.conf' for read.

    02.解决:进入awstats程序目录,本例为:/usr/local/awstats ,然后在运行perl /usr/local/awstats/tools/awstats_configure.pl

相关推荐