AWStats6.9インストールメモ

とある作業でCentOSAWStatsを入れた時の作業メモを忘れないように書いておく。

参考にしたのは、こちらのサイト。→CentOS5.3にてAWStats6.9でアクセスログ解析できるまでをイチから再構築 - カンタンWEBぷろぐらみんぐ<?=tageo;>


※以下の作業はrootユーザで実行する。

2.AWStatsの実行ディレクトリ作成
mkdir -p /var/lib/awstats
3.解凍(解凍先ディレクトリを/usr/localで指定)、ディレクトリリネーム
# tar zxvf awstats-6.9.tar.gz -C /usr/local
# mv /usr/local/awstats-6.9/ /usr/local/awstats/
4.権限ユーザ変更
# chown -R apache:apache /usr/;local/awstats/
# chown -R apache:apache /var/lib/awstats/
5.インストール設定ファイル実行(途中太字は入力する内容)
# cd /usr/local/awstats/tools/
# perl ./awstats_configure.pl
 ----- AWStats awstats_configure 1.0 (build 1.8) (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).

…(中略)…

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
    
…(中略)…
          • > 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] ? 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:
…(以下、入力画面は[Enter]で進める)…
6.設定ファイル編集
# vi awstats.sample.domain.conf
変更した場所は以下。
  • LogFile="/var/log/httpd/access_log"
  • DNSLookup=1
  • EnableLockForUpdate=1
  • Lang="jp"
7.解析用ファイル生成
# perl /usr/local/awstats/tools/awstats_updateall.pl now

Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=uos9.tixe-net.jp -configdir="/etc/awstats"' to update config sample.domain
Create/Update database for config "/etc/awstats/awstats.uos9.tixe-net.jp.conf" by AWStats version 6.9 (build 1.925)
From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Reverse DNS lookup for ::1 not available without ipv6 plugin enabled.
Jumped lines in file: 0
Parsed lines in file: 18435
 Found 6 dropped records,
 Found 2 corrupted records,
 Found 0 old records,
 Found 18427 new qualified records.

8.解析表示変更
# vi /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
  • 13231行目
else { print "$Message[5] $MonthNumLib{$MonthRequired} $YearRequired"; }
↓
else { print "$YearRequired $Message[6]".$MonthNumLib{$MonthRequired}; }
  • 15709行目
print ($MonthRequired eq 'all'?"$Message[6] $YearRequired":"$Message[5] ".$MonthNumLib{$MonthRequired}." $YearRequired");
↓
print ($MonthRequired eq 'all'?"$YearRequired $Message[6]":"$YearRequired $Message[6]".$MonthNumLib{$MonthRequired});
9.Apache再起動
# /etc/init.d/httpd restart
10.解析ページ確認
http://[ドメイン]/awstats/awstats.plでアクセスし、ページが生成されていることを確認。
11.定期解析
7.の生成だと1回のみの生成なので、定期的に解析させる。(Cronを使用し、1時間おきに解析するようにする。) ※Cronの細かい設定は省く。
# cd /etc/cron.hourly/
# echo /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=sample.domain >> awstats.cron
# crontab -l
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly