AWStatsでグラフィカルなアクセス解析を設置
AWStatsはWebalizerに比べ非常にグラフィカルで綺麗だ。
しかもたくさんのコンテンツからなり細かに分析でき眺めていても面白い。
CGIプログラムで動くので低スペックサーバはちょっと辛かった。
■Jcodeがインストールされていない場合はCPANを用いインストール。
perl -MCPAN -e shell
cpan> install Jcode
---------------------------------
Fetching with LWP:
ftp://ftp.dti.ad.jp/pub/lang/CPAN/modules/03modlist.data.gz
Going to read /root/.cpan/sources/modules/03modlist.data.gz
Going to write /root/.cpan/Metadata
Jcode is up to date (2.03).
---------------------------------
どうやらJcodeがアップデートされたようだ。
cpan> exit
Lockfile removed.
※初回のCPANでのインストールの際になにやら質問が出てくるので
下記のように回答した
---------------------------------
Select your continent (or several nearby continents) [] 2 ← Asia
Select your country (or several nearby countries) [] 7 ← Japan
Select as many URLs as you like (by number),
put them on one line, separated by blanks, e.g. '1 4 5' [] 1 4 5
---------------------------------
さて本題へ…
AWStatsをまず /usr/local/bin へ持ってくるとします。
そして展開
#cd /usr/local/bin
#wget http://www.bflets.dyndns.org/AWStats60_Jpn.tar.gz
#tar zxvf AWStats60_Jpn.tar.gz
CGIプログラムなのでcgi-binで動かさねば…
アイコン(画像ファイル)などもあるのでcgi-binのawstats直下へそのフォルダ(/icon)も作成。
#mkdir /home/httpd/html/cgi-bin/awstats
#mkdir /home/httpd/html/cgi-bin/awstats/icon
移動して設定ファイル、画像のコピーなどを行う。
# cd /usr/local/bin/AWStats60_Jpn/wwwroot/
# cp -rf cgi-bin/* /home/httpd/html/cgi-bin/awstats
# cp -rf icon/* /home/httpd/html/cgi-bin/awstats/icon
設定ファイル awstats.model.conf を awstats.conf リネーム。
そして EUC に変換。
# cd /home/httpd/html/cgi-bin/awstats
# nkf -ed awstats.model.conf > awstats.conf
設定ファイルの編集
#vi /home/httpd/html/cgi-bin/awstats/awstats.conf
55行目 LogFile="/var/log/httpd/access_log.utf8"
155行目 SiteDomain="******.com"
191行目 DNSLookup=1 ※ DNSの逆引きを行うように設定しなくてはならないと説明書にある。
216行目 DirCgi="/cgi-bin/awstats"
227行目 DirIcons="/cgi-bin/awstats/icon"
473行目 SkipHosts="127.0.0.1 REGEX[^192.168.0.]"
894行目 Lang="jp"#:wq
手動でApacheのログを変換し解析してみる。
#/home/httpd/html/cgi-bin/awstats/utf8_decode.pl <
/var/log/httpd/access_log >
/var/log/httpd/access_log.utf8
↑一行です
低スペックサーバだと非常にもたつきました…
ログファイルの存在を確認
#ls /var/log/httpd/access_log.utf8
手動で解析してみる
#/home/httpd/html/cgi-bin/awstats/awstats.pl -config=awstats.conf
-update
これも時間が非常にかかります
---------------------------------
# /home/httpd/html/cgi-bin/awstats/awstats.pl -config=awstats.conf -up
Update for config "/home/httpd/html/cgi-bin/awstats/awstats.conf"
With data in log file "/var/log/httpd/access_log.utf8"...
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: 10549
Found 108 dropped records,
Found 5 corrupted records,
Found 0 old records,
Found 10436 new qualified records.
---------------------------------
やっと出てきた…
# chown -R 所有者:グループ名 /home/httpd/html/cgi-bin/awstats
ブラウザで
http://*****.com/cgi-bin/awstats/awstats.pl
と確認してみる…
出てきた出てきた…(^。^;)ホッ!
起動スクリプトを作成しcronに登録してみる。
#cd
#vi awstats.sh
-------------------------------------
#!/bin/shALOG=/var/log/httpd/access_log
A1LOG=/var/log/httpd/access_log.1
NEWLOG=/var/log/httpd/access_log.new
UTF8LOG=/var/log/httpd/access_log.utf8
UTF8DECODE=/home/httpd/html/cgi-bin/awstats/utf8_decode.pl
AWSTATS=/home/httpd/html/cgi-bin/awstats/awstats.pl
LOG=/var/log/awstats.logcat $ALOG > $NEWLOG
cat $A1LOG >> $NEWLOG$UTF8DECODE < $NEWLOG > $UTF8LOG
$AWSTATS -config=awstats.conf -update > $LOG
chmod 600 $LOG
-------------------------------------
crontab -e で好きな時間帯へ…
00 05 * * * /root/awstats.sh
service crond restart
反映
スクリプトを実行そして確認
#./awstats.sh
#cat: /var/log/httpd/access_log
参考サイト様 : 『VineLinuxで自宅サーバ』 http://vine.1-max.net/
※とても親切でわかりやすく説明してあります。
初心者だけではなく忘れていたあんな事、こんな事が非常に丁寧に説明してあります。
質問掲示板もあります。
後記:
サーバ機を新しく構築したためにこれを機に今回AWStatsを導入したわけだが
日々のアクセス分析、検索用語、ROBOT、など結構細かにGUI環境で教えてくれるこのソフトは
使えると思いました。
ただ低スペックサーバでこのソフトを導入した際には
ログを見ることすら結構面倒になってしまった…(^^;