zj2092 发表于 2019-1-30 07:18:01

Awstats 日志分析工具安装

  最近工作当中需要对Apache访问日志进行分析,一开始用脚本分析,但是没有图形化工具那么直观,于是在网上找到了awstats工具,这里记录一下它的安装过程和使用方法!
  一、安装(安装之前确保服务器上已经安装了perl,和lamp环境,否则将无法安装)
  1、从awstats官方网站上下载awstats源码包
  cd /usr/local

  wget http://jaist.dl.sourceforge.net/project/awstats/AWStats/7.3/awstats-7.3.tar.gz

  2、解压安装awstats
  cd /usr/local/

  tar -zxvf awstats-7.3.tar.gz
  mkdir /etc/awstats

  mkdir /var/lib/awstats

  mv awstats-7.3 awstats
  3、配置awstats_configure.pl
  cd /usr/loca/awstats/tools/

  查看awstats_configure.pl,确保以下变量设置是正确的(所有路径需根据现实环境而定)
  $AWSTATS_PATH='';
  $AWSTATS_ICON_PATH='/usr/local/awstats/wwwroot/icon';
  $AWSTATS_CSS_PATH='/usr/local/awstats/wwwroot/css';
  $AWSTATS_CLASSES_PATH='/usr/local/awstats/wwwroot/classes';
  $AWSTATS_CGI_PATH='/usr/local/awstats/wwwroot/cgi-bin';
  $AWSTATS_MODEL_CONFIG='/etc/awstats/awstats.model.conf';
  $AWSTATS_DIRDATA_PATH='/var/lib/awstats';
  4、运行配置文件

  cd /usr/loca/awstats/tools

  /usr/bin/perl awstats_configure.pl

  # perl awstats_configure.pl
  -----> Running OS detected: Linux, BSD or Unix
  Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
  If you want to use standard directory, you should first move all content
  of AWStats distribution from current directory:
  /usr/local/wwwroot/awstats
  to standard directory:
  /usr/local/awstats
  And then, run configure.pl from this location.
  Do you want to continue setup from this NON standard directory ? y
      .

      .

      .

  -----> Need to create a new config file ?
  Do you want me to build a new AWStats config/profile
  file (required if first install) ? Y
      .

      .
      .

      -----> Define config file name to create
  What is the name of your web site or profile analysis ?
  Example: www.mysite.com
  Example: demo
  Your web site, virtual server or profile name:
  > demo(可以自定义)
  -----> 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):
  > Y
  接下来就是一路回车就可以了!!!!

  5、指定需要进行分析的log路径
  vi /etc/awstats/awstats.demo.conf
  LogFile="/usr/local/apache/logs/dummy-t.new.dodoca.com-access-2014_06_05.log"
  此路径以现实环境为准

  6、分析日志

  cd /usr/local/awstats/wwwroot/cgi-bin/

  perl ./awstats.pl -update -config=demo (此处demo为第4步中定义的,如果分析多个日志,依次为区分)

  出现类似以下输出,表示ok,否则需根据输出的错误信息进行debug
  一般会有Apache accesslog类型不是combined错误,去Apache配置文件中将其改为combined.
  perl ./awstats.pl -update -config=demo
  Create/Update database for config "/etc/awstats/awstats.demo.conf" by AWStats version   7.3 (build 20140126)
  From data in log file "/usr/local/apache/logs/dummy-t.new.dodoca.com-access-    2014_06_05.log"...
  Phase 1 : First bypass old records, searching new record...
  Direct access after last parsed record (after line 12492)
  Jumped lines in file: 12492
  Found 12492 already parsed records.
  Parsed lines in file: 31
  Found 0 dropped records,
  Found 0 comments,
  Found 0 blank records,
  Found 0 corrupted records,
  Found 0 old records,
  Found 31 new qualified records.
  7、apache
  




页: [1]
查看完整版本: Awstats 日志分析工具安装