centos

CentOS6.3マルチドメイン、バーチャルホスト追加時、awstatsの設定

マルチドメイン、バーチャルホストを利用の際、ログファイルをドメイン、バーチャルホスト毎に分けて保存する場合の追加設定です。

1、apacheのhttpd.confファイルを編集し、ログにバーチャルホスト名を記載するようにします。

# nano /etc/httpd/conf/httpd.conf
LogFormat "%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined #でvirtualhost名を指定

※初めて、awstats利用の場合、先にyum install awstatsを実行の必要があります。

2、/etc/awstats/の下に、ドメイン、バーチャルホスト毎にawstatsの設定ファイルを作成して、編集しておきます。

LogFormat = "%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot" #vitualnameの指定が必要
DNSLookup=1 #訪問者のドメイン名を表示

 

3、/etc/httpd/conf.d/vhost.confを開いて、ドメイン、バーチャルホスト毎にログファイルの保存場所を指定しておきます。これでログは指定ファイルへ書き込まれるはずです。

ErrorLog "/var/log/httpd/ドメイン_error_log"
CustomLog "/var/log/httpd/ドメイン_access_log" combined

4、httpを再起動します。

# service httpd restart

5、 crontab を実行して、6時間毎に解析取得するようにドメイン、バーチャルホスト毎に設定しておきます。

# crontab -e
00 0-23/6 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=ドメイン > /dev/null

6、ブラウザから[http://サーバーIPアドレス/awstats/awstats.pl?config=ドメイン名=]でアクセスするとawstatsの解析結果が表示されます。

http://ドメイン/awstats/awstats.pl?config=ドメイン

ロボット・ドローン部品お探しなら
ROBOT翔・電子部品ストア