elanbeat's wiki
LighttpdWebalizer

webalizerによるlighttpdのログ解析

以下、ディレクトリ構成などはFedoraを想定。

webalizerのインストール


#yum install webalizer

設定

/etc/webalizer.confを編集。ログファイルの位置と出力先のディレクトリをlighttpdに合わせる。


LogFile        /var/log/lighttpd/access_log
OutputDir      /srv/www/lighttpd/usage

同様に/etc/cron.daily/00webalizer内のログファイル位置を編集。


#! /bin/bash
# update access statistics for the web site

if [ -s /var/log/lighttpd/access_log ] ; then
    /usr/bin/webalizer
fi

exit 0

テスト

webalizerを起動してusage下に解析結果が生成されることを確認する。


#webalizer

認証

/usageに認証を設定する。


バーチャルホストで結果を切り替える

/etc/lighttpd.confでバーチャルホストごとにログを設定しておく。


$ mkdir /srv/www/lighttpd/usage/vhost
$ mkdir /etc/webalizer
$ cp /etc/webalizer.conf /etc/webalizer/vhost.conf
$ vi /etc/webalizer/vhost.conf
$ cat /etc/webalizer/vhost.conf
LogFile /var/log/lighttpd/vhost.access_log
OutputDir /srv/www/lighttpd/usage/vhost
HistoryName /var/lib/webalizer/vhost.hist
IncrementalName /var/lib/webalizer/vhost.current
HostName       vhost


$ vi /etc/cron.daily/00webalizer
$ cat /etc/cron.daily/00webalizer
#! /bin/bash
# update access statistics for the web site

if [ -s /var/log/lighttpd/access_log ] ; then
    /usr/bin/webalizer
fi
if [ -s /var/log/lighttpd/vhost.access_log ] ; then
    /usr/bin/webalizer -c /etc/webalizer/vhost.conf
fi
exit 0