#tar xzvf awstats-6.7.tar.gz #ls awstats-6.7/ README.TXT docs tools wwwroot #ls awstats-6.7/wwwroot/ cgi-bin classes css icon js #ls awstats-6.7/wwwroot/cgi-bin/ awredir.pl awstats.model.conf awstats.pl lang lib plugins次に以下のことを確認します。
#perl -v This is perl, v5.8.3 built for i386-linux-thread-multi2.perlの場所を確認します。
#which perl /usr/bin/perl3.WWWサーバのCGIディレクトリのパスを確認します。(この文章では/usr/local/apache/cgi-binとします。)
#vi /usr/local/apache/conf/httpd.conf
----------------省略---------------- # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a# container, they will be logged here. Contrariwise, if you *do* # define per- access logfiles, transactions will be # logged therein and *not* in this file. # #CustomLog /var/log/httpd/access_log common ←コメントアウトする。 ----------------省略---------------- # # If you prefer a single logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # CustomLog /var/log/httpd/access_log combined ←コメントアウトを解除する。 ----------------省略----------------
#cp -r awstats-6.7/wwwroot/cgi-bin/* /usr/local/apache/cgi-bin/AWStatsが使用するアイコンファイルが格納されたディレクトリをWWWサーバから見える場所にコピーします。
#cp -r awstats-6.7/wwwroot/icon/ /usr/local/apache/htdocs/以上でインストール完了です。
#cd /usr/local/apache/cgi-bin/ #mv awstats.model.conf awstats.confそしてこのAWStatsの設定ファイル(awstats.conf)を編集します。編集する項目は次のとおりです。(Apacheのログファイルを分析する。)
| 項目 | 値 | 説明 |
| LogFile | /usr/local/apache/logs/access_log | 分析するWWWサーバのアクセスログファイルのパスを指定する。(絶対パスもしくはawstats.plからの相対パス) |
| LogType | W | 分析するログファイルのタイプを指定します。(W:web S:streaming M:mail F:ftp) |
| LogFormat | 1 | ログフォーマットを指定する。(Apache:1 IIS:2) |
| SiteDomain | ドメイン名 | 分析対象のWWWサーバのドメイン名を指定する。 |
| HostAliases | ドメイン名 | IPアドレス | SiteDomainで指定したドメイン名以外で分析対象のWWWサーバにアクセスできるドメイン名やIPアドレスを指定する。 |
| DNSLookup | 1 | ドメイン/国別などの統計情報を取得する場合はDNSの逆引きをする必要があります。 (0:逆引きしない 1:逆引きする 2:DNSキャッシュ内のIPアドレスのみ逆引きする |
| DirData | ./awstats_db | AWStatsが保持する分析結果などのファイルを格納するディレクトリを指定します。(絶対パスもしくはawstats.plからの相対パス) |
| DirCgi | /cgi-bin | awstats.plが格納されているディレクトリを指定する。(絶対URLもしくはWWWサーバのルートディレクトリからの相対URL) |
| DirIcons | /icon | アイコンファイルが格納されているディレクトリを指定する。(絶対URLもしくはWWWサーバのルートディレクトリからの相対URL) |
| AllowToUpdateStatsFromBrowser | 0 | 出力するHTMLファイルに更新ボタンを設置するか指定します。この更新ボタンからの動作はApacheのユーザ権限で 動作するためそのユーザにDirDataで指定されたディレクトリやファイルへの書き込み権限が必要です。(0:設置しない 1:設置する) |
| AllowFullYearView | 3 | 年間統計情報を出力できるか指定する。(0:許可しない 1:コマンドライン上では許可、出力されたHTML上のコンボボックスには表示されない 2:コマンドライン上では許可、出力されたHTML上のコンボボックスからは許可しない 3:許可する) |
| PurgeLogFile | 0 | AWStats実行時にLogFileで指定したログファイルを切り詰めるか指定します。動作が安定するまでは切り詰めを行わないこと をお勧めします。(0:切り詰めない 1:切り詰める) |
| SkipHosts | ホスト名 | IPアドレス | 統計情報の処理対象外にするクライアントを指定する。ログファイルの時点で逆引きされている場合はホスト名 で指定し、されていない場合はIPアドレスで指定する。(自分からのアクセスは統計に含みたくない場合は自分のIPアドレスを記述すればよい。) |
| Lang | 言語 | 統計情報で表示される言語を指定する。日本語で表示させるならjaです。 |
#/usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -update #/usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -output -staticlink > /usr/local/apache/htdocs/awstats.htmlhttp://ドメイン名/awstats.htmlでブラウザから閲覧できるか確認します。
#cp conv_weblog_to_utf8.pl /usr/local/apache/cgi-bin/このスクリプトにApacheのアクセスログを通すことでApacheのアクセスログ内の検索文字列がutf8に変換されます。(変換後のアクセスログはaccess_log.enc)
#/usr/local/apache/cgi-bin/conv_weblog_to_utf8.pl < /usr/local/apache/logs/access_log > /usr/local/apache/logs/access_log.encこれでaccess_log内の検索文字列はutf8に変換されaccess_log.encに出力されます。
LogFile="/usr/local/apache/logs/access_log.enc"統計情報を更新します。
/usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -update最後にHTML形式で統計情報を出力します。
/usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -output -staticlink > /usr/local/apache/htdocs/awstats.html
下線部には出力させたいパスを記述します。(絶対パスもしくはawstats.plからの相対パス)#vi /usr/local/apache/cgi-bin/lang/awstats-jp.txt
# Japanese message file (info@kchosting.jp) # $Revision: 1.9 $ - $Date: 2004/06/07 19:04:36 $ PageCode=UTF-8 message0=不明 message1=不明(ipが解りません) message2=その他 message3=詳細を見る message4=日 message5=月 message6=年 ----------------省略----------------上記のように設定されているので、これらを編集すれば自分のわかりやすい日本語表示にすることができる。しかし、これら(message)がどの表示部分に対応しているかを 調べる必要がある。私が修正したファイルを置いておきます。(右クリック→対象をファイルに保存)awstats-jp.txt




----------------省略---------------- %DomainsHashIDLib = ( 'localhost','localhost', 'i0','Local network host', 'a2','Satellite access host', 'ac','Ascension Island','ad','Andorra','ae','United Arab Emirates', 'aero','Aero/Travel domains','af','Afghanistan', 'ag','Antigua and Barbuda','ai','Anguilla','al','Albania', ----------------省略---------------- );’TLD(トップレベルドメイン)’,’表示名’というフォーマットになっているのでこの表示名の部分を日本語で編集してください。


----------------省略----------------
@SearchEnginesSearchIDOrder_list1=(
# Major international search engines
'base\.google\.',
'froogle\.google\.',
'groups\.google\.',
'images\.google\.',
'google\.',
'googlee\.',
'googlecom\.com',
'goggle\.co\.hu',
'216\.239\.(35|37|39|51)\.100',
'216\.239\.(35|37|39|51)\.101',
'216\.239\.5[0-9]\.104',
'64\.233\.1[0-9]{2}\.104',
'66\.102\.[1-9]\.104',
'66\.249\.93\.104',
'72\.14\.2[0-9]{2}\.104',
'msn\.',
----------------省略----------------
私が修正したファイルを置いておきます。search_engines.pm
→ 
#vi /etc/cron.hourly/awstats.cron
#!/bin/sh /usr/bin/perl /usr/local/apache/cgi-bin/conv_weblog_to_utf8.pl < /usr/local/apache/logs/access_log > /usr/local/apache/logs/access_log.enc /usr/bin/perl /usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -update > /dev/null /usr/bin/perl /usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -output -staticlink > /usr/local/apache/htdocs/awstats.htmlパーミッションを変更します。
#chmod 700 /etc/cron.hourly/awstats.cronこの動作はまず
#vi /etc/logrotate.d/apache
/usr/local/apache/logs/access_log {
missingok
prerotate
/usr/bin/perl /usr/local/apache/cgi-bin/conv_weblog_to_utf8.pl < /usr/local/apache/logs/access_log > /usr/local/apache/logs/access_log.enc
/usr/bin/perl /usr/local/apache/cgi-bin/awstats.pl -config=awstats.conf -update > /dev/null
endscript
postrotate
/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid`
endscript
}
下線部を追記します。これでaccess_logをローテーションする直前に統計情報がアップデートされるので問題が発生しません。#vi /usr/local/apache/conf/http.conf
SetEnvIf Request_URI "default\.ida" wormlog SetEnvIf Request_URI "cmd\.exe" wormlog SetEnvIf Request_URI "root\.exe" wormlog SetEnvIf Request_URI "Admin\.dll" wormlog SetEnvIf Request_URI "NULL\.IDA" wormlog SetEnvIf Request_URI "NULL\.printer" wormlog SetEnvIf Request_URI "mem_bin" wormlog SetEnvIf Request_URI "vti_bin" wormlog SetEnvIf Request_URI "MSADC" wormlog CustomLog /usr/local/apache/logs/access_log combined env=!wormlog CustomLog /usr/local/apache/logs/worm_log combined env=wormlog上記のように SetEnvIf を追記し CustomLog を編集してください。これにより、NimdaやCode Red、Code Blueなどによるログはaccess_logではなくworm_logに記録されます。
[12/Mar/2004:20:14:15 +0900] "SEARCH /\x90\x02\xb1\x02\xb1\x02\xb1\x02\xb1\x02 …というものが延々記録されます。このログは SetEnvIf では回避できません。(URIが長すぎることによる414エラー(Request-URI Too Long)に対するログのほうが先に判断されるため。)
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat に上記下線部を追記してください。以上で、ステータスコード414エラーによるログは記録されなくなります。