Scientific Linux 6
Sponsored Link

Apache アクセスログ解析 - AWstats2011/03/20

 
アクセスログ解析ツール AWstats をインストールします。
[1] AWstats インストール
[root@www ~]#
yum --enablerepo=rpmforge -y install awstats
 
# RPMforgeからインストール
[root@www ~]#
cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.www.srv.world.conf

[root@www ~]#
vi /etc/awstats/awstats.www.srv.world.conf
# 122行目:変更

# Apache のログフォーマットが"combined"の場合は「1」

# "common"の場合は「4」( ただしこの場合ブラウザ情報等、一部の解析はできなくなる)

LogFormat=
1
# 153行目:ホスト名指定

SiteDomain="
www.srv.world
"
# 168行目:除外するドメイン名/IPアドレス追記

HostAliases="
localhost 127.0.0.1 REGEX[server\.world$] REGEX[^10\.0\.0\.]
"
# 905行目:変更

Lang="
jp
"
[root@www ~]#
vi /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
# Alias 追記

Alias /report /var/www/awstats/

ScriptAlias /awstats/ /var/www/awstats/
<Directory "/var/www/awstats">
    DirectoryIndex awstats.pl
    Options ExecCGI
    order deny,allow
    deny from all
    allow from 127.0.0.1
10.0.0.0/24
# アクセス許可IP追記

</Directory>
[root@www ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[  OK  ]

Starting httpd:
[  OK  ]
# レポート出力

[root@www ~]#
/var/www/awstats/awstats.pl -config=www.srv.world -update

Create/Update database for config "/etc/awstats/awstats.www.srv.world.conf" by AWStats version 7.0 (build 1.971)
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)...
Jumped lines in file: 0
Parsed lines in file: 11
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 11 new qualified records.
# 出力したレポートをHTMLにする

[root@www ~]#
/var/www/awstats/awstats.pl -config=www.srv.world -output -staticlink > /var/www/awstats/index.html
# cronの内容を変更しておく

[root@www ~]#
vi /etc/cron.hourly/00awstats
#!/bin/bash
if [ -f /var/log/httpd/access_log ] ; then
# コメント化

#
exec /usr/bin/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/var/www/awstats/awstats.pl" > /dev/null
# 追記

/var/www/awstats/awstats.pl -config=www.srv.world -update > /dev/null
/var/www/awstats/awstats.pl -config=www.srv.world -output -staticlink > /var/www/awstats/index.html

fi
exit 0
[2] 「http://(サーバーのホスト名またはIPアドレス/)/report/index.html」にアクセスすると、 以下のような画面が表示されApacheのログを見ることができます。
関連コンテンツ