Webアクセス解析ツールのAWStatsを入れました。
Apacheのログ形式が、combinedになっている必要があります。
[root@sv01 ~]# wget http://easynews.dl.sourceforge.net/sourceforge/awstats/awstats-6.5-1.noarch.rpm
[root@sv01 ~]# rpm -ivh awstats-6.5-1.noarch.rpm
AWStatsのセットアップスクリプトを起動し、自分のサーバに合った設定をしていきます。
[root@sv01 ~]# /usr/local/awstats/tools/awstats_configure.pl
その後、/etc/awstats/awstats.wk64.com.conf を必要に応じて編集します。
LogFile="/var/log/httpd/mylog.log"
LogFile="/etc/httpd/logs/access_log"
SiteDomain=""
SiteDomain="wk64.com"
HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]"
HostAliases="wk64.com www.wk64.com 127.0.0.1 localhost"
DirData="/var/lib/awstats"
DirData="."
AllowFullYearView=2
AllowFullYearView=3
SkipHosts=""
SkipHosts="127.0.0.1 REGEX[^172\.16\.]"
SkipFiles=""
SkipFiles="REGEX[^\/mt\/mt\.cgi] REGEX[^\/awstats]"
LevelForWormsDetection=0 # 0 disables Worms detection.
LevelForWormsDetection=2 # 0 disables Worms detection.
Lang="auto"
Lang="jp"
FirstDayOfWeek=1
FirstDayOfWeek=0
また、httpd.conf の最後尾にAWStats関連の設定が追記されているので、必要に応じて編集します。
コメントをはずすのと、うちの場合はディレクトリ構成を変えたので、それを反映させました。
検索キーワードなどの文字化けを防ぐために、ひろせ まさあきさんのサイトで公開されている、「AWStatsの検索文字列の文字化けを解消」の方法をとらせていただきました。CentOSのx86_64版でも、同じ手順で適用できます。
最後に、集計処理用のシェルスクリプトを作成し、定期的に実行するようにします。
[root@sv01 ~]# vi /root/jobs/awstats.sh
#!/bin/sh
year="`date +"%Y"`"
month="`date +"%m"`"
day="`date +"%d"`"
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com -update
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output -year=$year -month=$month -staticlinks > \
/var/www/html/awstats/$year-$month.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=alldomains -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.alldomains.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=allhosts -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.allhosts.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=lasthosts -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.lasthosts.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=unknownip -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.unknownip.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=allrobots -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.allrobots.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=lastrobots -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.lastrobots.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=urldetail -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.urldetail.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=urlentry -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.urlentry.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=urlexit -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.urlexit.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=osdetail -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.osdetail.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=unknownos -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.unknownos.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=browserdetail -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.browserdetail.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=unknownbrowser -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.unknownbrowser.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=refererse -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.refererse.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=refererpages -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.refererpages.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=keyphrases -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.keyphrases.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=keywords -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.keywords.html
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wk64.com \
-output=errors404 -staticlinks > \
/var/www/html/awstats/awstats.wk64.com.errors404.html
[root@sv01 ~]# chmod 700 /root/jobs/awstats.sh
[root@sv01 ~]# crontab -e
00 0-23/3 * * * /root/jobs/awstats.sh | nkf -j
|