网络通信 频道

网站日志处理工具Awstats:处理多Apache日志

  四、 配置Awstats系统
  1、 安装Awstats。
  (1) 下载Awstats 
  wget http://downloads.sourceforge.net/Awstats/Awstats-6.7.tar.gz?modtime=1183813789&
  big_mirror=0
  (2) 解压
  tar  xvf  wstats-6.7.tar.gz
  mv Awstats-6.7  /usr/local/Awstats
  Awstats需要Apache协同工作,请自行安装之。Apache安装好以后,运行命令/usr/local/Apache/bin/httpd -l | grep mod_cgi.c 看是否把模块编译进来,这个模块是必须的。接着再检查perl工具是否被安装到系统,如果没有安装,请手动安装。

  2、 配置Awstats。
  cd /usr/local/Awstats/tools
  执行配置脚本,这是一个交互程序,可根据自己的实际情况回答
  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] ?
  执行完配置后,将生成配置文件/etc/aswstats/ Awstats.sery.conf,修改
  LogFile=/root/logs/Awstats_log/17k.com-access.log
  然后再执行 perl /usr/local/Awstats/wwwroot/cgi-bin/Awstats.pl -config=sery.com -update 如果没有错误的话,在浏览器输入Awstats服务器的ip地址即可得到访问日志报告。我们不想无关的人看见日志报告,用Apache用户验证功能来完成,把下面的内容加入到Apache配置文件httpd.conf即可:
      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>
  把Awstats更新加入 crontab,让它每天自动执行一次。
  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
  每天早上6点会自动执行一次更新操作,对日志文件进行处理,最后在浏览器里读出所需数据。
  
  输入正确的用户名和密码

0
相关文章