各ログアナライザのインストールと設定についてのメモ。
# vi /usr/local/apache2/conf/httpd.conf (変更前)CustomLog /usr/local/apache/logs/access_log common (変更後)CustomLog /usr/local/apache/logs/access_log combinedApacheの再起動
# /usr/local/apache2/bin/apachectl restart
# vi /usr/local/apache2/conf/ssl.conf ErrorLog /usr/local/apache2/logs/error_log (追加)LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" TransferLog /usr/local/apache2/logs/access_log
RedHat ProfessionalWorstation(以降RHEL3と表記する)における日本語表記化及びWebminを利用する場合の導入手順
以下のパッケージを用意する(別に最新版でも構わない)
パッケージ名 | 場所 |
webalizer-2.01_10-15.ent.src.rpm | RHEL3 ソースコードCD 2/3 |
libpng-1.2.2-16.i386.rpm | RHEL3 インストールCD 2/4 |
libpng-devel-1.2.2-16.i386.rpm | RHEL3 インストールCD 3/4 |
gd-1.8.4-12.i386.rpm | RHEL3 インストールCD 2/4 |
gd-devel-1.8.4-12.i386.rpm | RHEL3 インストールCD 3/4 |
webmin-1.180-1.noarch.rpm(2005/01/25時点での最新版) | http://www.webmin.com |
# rpm -Uvh webalizer-2.01_10-15.ent.src.rpm # rpm -Uvh libpng-1.2.2-16.i386.rpm # rpm -Uvh libpng-devel-1.2.2-16.i386.rpm # rpm -Uvh gd-1.8.4-12.i386.rpm # rpm -Uvh gd-devel-1.8.4-12.i386.rpm # rpm -Uvh webmin-1.170-1.noarch.rpm
# vi /usr/src/redhat/SPECS/webalizer.spec (変更前)%configure --enable-dns --with-dblib=/lib (変更後)%configure --with-language=japanese --enable-dns --with-dblib=/lib
# rpmbuild --ba /usr/src/redhat/SPECS/webalizer.spec
# rpm -e webalizer-2.01_10-15.ent.rpm
# rpm -Uvh --nodeps /usr/src/redhat/RPMS/i386/webalizer-2.01_10-15.ent.i386.rpm
# mv /etc/webalizer.conf /etc/webalizer.conf.original # mv /etc/webalizer.conf.rpmsave /etc/webalizer.conf
解析ログはApacheからは見えなくWebminからはアクセス出来る「/var/www/analyze」に配置。
# vi /etc/webalizer.conf (追加)SearchEngine google.co.jp q= (追加)SearchEngine yahoo.co.jp p= (追加)SearchEngine msn.co.jp MT= (追加)SearchEngine goo.ne.jp MT= (追加)SearchEngine clusty.com query= (追加)SearchEngine fresheye.com kw= (追加)SearchEngine infoseek.co.jp qt= (追加)SearchEngine altavista.com q=
RedHat ProfessionalWorstation(以降RHEL3と表記する)におけるの導入手順(Webminでも利用できるようにする)
パッケージ名 | アーカイブ名 | 場所 | 備考 |
AWStats | awstats-6.2-1.noarch.rpm | http://awstats.sf.net | /.J アクセス解析ツールのバグで、人気Blogが改竄される セキュリティ上問題があるので6.3以降をSetupする事 |
GeoIP | GeoIP-1.3.8.tar.gz | http://www.maxmind.com/app/c |
「秘密」の部分は文字通り秘密(内緒)です。つまり自分の環境に依存する部分です。
# rpm -Uvh awstats-6.2-1.noarch.rpm
# cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.conf
# mkdir /usr/local/apache2/htdocs/秘密 # cp -R /usr/local/awstats/wwwroot /usr/local/apache2/htdocs/秘密 # chown -R nobody.nobody /usr/local/apache2/htdocs/秘密 # chmod -R 644 /usr/local/apache2/htdocs/秘密
※内容が反映されるのは変更後に集計したもののみになるので注意
# vi /etc/awstats/awstats.conf (変更)LogFile="/usr/local/apache2/logs/access_log" (変更)SiteDomain="秘密" (変更)HostAliases="秘密 localhost 127.0.0.1 REGEX[秘密$]" (変更)DNSLookup="1" (変更)DirCgi="/秘密/cgi-bin" (変更)DirIcons="/秘密/icon" (変更)DefaultFile="index.html index.php index.jsp" (変更)SkipDNSLookupFor="REGEX[^192\.168\.]" (変更)URLWithQuery=1 (変更)Lang="jp" (変更)ShowAuthenticatedUsers=PHBL
秘密
AWStats集計負荷を軽減するPlug-inが存在するようなので追加する。
# tar zxf GeoIP-1.3.8.tar.gz # cd GeoIP-1.3.8 # ./configure # make # make check # make install
国別IPアドレス調査処理速度の向上。
DNSのキャッシュファイルアクセス処理速度の向上。
# vi /etc/awstats/awstats.conf (変更)LoadPlugin="hashfiles" (変更)LoadPlugin="geoip GEOIP_STANDARD"
日本のサーチエンジン判定及び検索語の全角スペース検知のパッチ適用を行う。
http://cubic9.com/Linux/Apache/%A5%ED%A5%B0%B2%F2%C0%CF/AWStats/
上記サイトで公開されている「search_engines.diff」「searchwords.diff」をDownloadする。
# cd /usr/local/apache2/htdocs/秘密/cgi-bin # patch < /path-to-patch-file-dir/searchwords.diff # cd /usr/local/apache2/htdocs/秘密/cgi-bin/lib # patch < /path-to-patch-file-dir/search_engines.diff
# /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=/etc/awstats/awstats.conf \ -update
# vi /usr/local/apache2/htdocs/秘密/cgi-bin/lib/search_engines.pm (変更前)'excite\.' (変更前)'a9\.com' (変更後)'excite\.', (変更後)'a9\.com'
# vi /usr/local/apache2/htdocs/秘密/cgi-bin/lib/search_engines.pm (変更前)'google\.', '216\.239\.(37|39|41|51|53|57|59)\.104', '66\.102\.(7|9|11)\.104', '64\.233\.(161|167|171|179|183|185)\.104', (変更後)'google\.', '216\.239\.(37|39|41|51|53|57|59|63)\.104', '66\.102\.(7|9|11)\.104', '64\.233\.(161|167|171|179|183|185|187|189)\.104',※パッチ適用後に集計された分から、パッチで変更された部分が反映される。
# /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=/etc/awstats/awstats.conf \ -update
処理負荷はそれ程無いので毎時で実行しても良い。集計結果の表示は動的にHTMLを生成するので負荷が掛かる。
/usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=/etc/awstats/awstats.conf \ -update \ >/dev/null
AWStatsにはJavaWebStartによるアクセス表示アイコンが存在していないようだ。
./icon/browser/javaws.png ./icon/mime/jnlp.png
集計オプションを変更した場合、変更以後に集計したものが対象になる。
再集計を行うには、現在存在する集計結果を削除し、対象月のログを古いものから集計していく。
# cd /usr/local/apache2/htdocs/秘密/cgi-bin # mv awstats012005.txt awstats012005.txt.bak
# vi /etc/awstats/awstats.conf (変更前)LogFile="/usr/local/apache2/logs/access_log" (変更後)LogFile="/usr/local/apache2/logs/access_log.1" ←適宜開始月のログファイルを指定する。
適宜最新のログファイルになる迄、編集→集計を繰り返す
# /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=/etc/awstats/awstats.conf \ -update
バーチャルホスト名を「www.subdomain.example.com」「www.unknown.com」「www.notexist.com」とした場合
# cp /etc/awstats/awstats.model.conf \ /etc/awstats/awstats.www.subdomain.example.com.conf # cp /etc/awstats/awstats.model.conf \ /etc/awstats/awstats.www.unknown.com.conf # cp /etc/awstats/awstats.model.conf \ /etc/awstats/awstats.www.notexist.conf
# /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=www.subdomain.example.com \ -update # /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=www.unknown.com \ -update # /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=www.notexist.com \ -update
http://www.subdomain.example.com/秘密/cgi-bin/awstats.pl?configdir=/etc/awstats&config=www.subdomain.example.com http://www.unknown.com/秘密/cgi-bin/awstats.pl?configdir=/etc/awstats&config=www.unknown.com http://www.notexist.com/秘密/cgi-bin/awstats.pl?configdir=/etc/awstats&config=www.notexist.com
設定名称 | 設定内容 |
AWStatsのインストール場所 | /usr/local/awstats |
AWStatsの設定ファイルの場所 | /etc/awstats |
AWStatsのURL | http://www.example.com/秘密/cgi-bin/ |
使用するAWStatsのPlugin | HashFiles, GeoIP |
メールサーバ名 | mail.example.com |
メールサーバ用の設定ファイル名 | awstats.mail.example.com.conf |
メールサーバのログファイル名 | /var/log/maillog |
「秘密」の部分は文字通り秘密(内緒)です。つまり自分の環境に依存する部分です。
# cp /etc/awstats/awstats.model.conf \ /etc/awstats/awstats.mail.example.com.conf
# vi /etc/awstats/awstats.mail.example.com.conf (変更)LogFile="perl /usr/local/awstats/tools/maillogconvert.pl standard < /var/log/maillog |" (変更)LogType=M (変更)LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd" (変更)SiteDomain="秘密" (変更)HostAliases="秘密 localhost 127.0.0.1 REGEX[秘密$]" (変更)DNSLookup="1" (変更)DirCgi="/秘密/cgi-bin" (変更)DirIcons="/秘密/icon" (変更)LevelForBrowsersDetection=0 # 0 disables Browsers detection. (変更)LevelForOSDetection=0 # 0 disables OS detection. (変更)LevelForRefererAnalyze=0 # 0 disables Origin detection. (変更)LevelForRobotsDetection=0 # 0 disables Robots detection. (変更)LevelForSearchEnginesDetection=0 # 0 disables Search engines detection. (変更)LevelForFileTypesDetection=0 # 0 disables File types detection. (変更)LevelForWormsDetection=0 # 0 disables Worms detection. (変更)Lang="jp" (変更)ShowRobotsStats=0 (変更)ShowEMailSenders=HBML (変更)ShowEMailReceivers=HBML (変更)ShowPagesStats=0 (変更)ShowFileTypesStats=0 (変更)ShowOSStats=0 (変更)ShowBrowsersStats=0 (変更)ShowOriginStats=0 (変更)ShowKeyphrasesStats=0 (変更)ShowKeywordsStats=0 (変更)ShowMiscStats=0 (変更)ShowHTTPErrorsStats=0 (変更)ShowSMTPErrorsStats=1 (変更)LoadPlugin="hashfiles" (変更)LoadPlugin="geoip GEOIP_STANDARD"
# /usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=mail.example.com \ -update
処理負荷はそれ程無いので毎時で実行しても良い。集計結果の表示は動的にHTMLを生成するので負荷が掛かる。
/usr/local/apache2/htdocs/秘密/cgi-bin/awstats.pl \ -config=mail.example.com \ -update \ >/dev/null
http://www.example.com/秘密/cgi-bin/awstats.pl?configdir=/etc/awstats&config=mail.exapmle.com