はじめての自宅サーバ構築 - Fedora/CentOS -
Last Update 2018/05/30
[ 更新履歴 ] [ サイト マップ ] [ 質問掲示板 ] [ 雑談掲示板 ] [ リンク ]
トップ >> Webサーバ >> Webページアクセスログ解析(Webalizer)
動作確認 [ FC1 / FC2 / FC3 / FC4 / FC5 / FC6 / Fedora7 / Fedora8 / Fedora9 / Fedora10 / Fedora11 / Fedora12 / Fedora13 / Fedora14 / Fedora15 / Fedora16 / Fedora17 / CentOS4 / CentOS5 / CentOS6 ]
  1. webalizerとは・・・
  2. webalizerのインストール
  3. apacheのアクセスログを日本語コードに変換するスクリプトを作成
  4. webalizerの設定
    Fedora系の場合
    CentOS系の場合
  5. webalizerの動作確認

■ webalizerとは・・・

グラフィカルなWebサーバ(apache)へのアクセスログ解析ツールです。
導入することにより、日別・時間別・アクセス先など様々な情報をHTMLで見ることが出来ます。

■ webalizerのインストール

webalizerインストール
# yum -y install webalizer

■ apacheのアクセスログを日本語コードに変換するスクリプトを作成

スクリプトが使用する「Jcode」のインストール
# yum -y install perl-Jcode


日本語変換スクリプトの作成
# vi jconvertlog.pl
#!/usr/bin/perl
use Jcode;

open (IN ,$ARGV[0]);
while (<IN>){
    $_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    Jcode::convert(\$_,euc);
    print $_;
}
close (IN);
exit;

パーミッション変更(実行権付与)
# chmod 700 jconvertlog.pl

■ webalizerの設定

webalizer設定ファイルの編集
# vi /etc/webalizer.conf
# LogFile defines the web server log file to use.  If not specified
# here or on on the command line, input will default to STDIN.  If
# the log filename ends in '.gz' (ie: a gzip compressed file), it will
# be decompressed on the fly as it is being read.

アクセスログを指定
LogFile        /var/log/httpd/jaccess_log

# HostName defines the hostname for the report.  This is used in
# the title, and is prepended to the URL table items.  This allows
# clicking on URL's in the report to go to the proper location in
# the event you are running the report on a 'virtual' web server,
# or for a server different than the one the report resides on.
# If not specified here, or on the command line, webalizer will
# try to get the hostname via a uname system call.  If that fails,
# it will default to "localhost".

ホスト名を指定
HostName       fedora.kajuhome.com

# ReallyQuiet will supress all messages including errors and
# warnings.  Values can be 'yes' or 'no' with 'no' being the
# default.  If 'yes' is used here, it cannot be overriden from
# the command line, so use with caution.  A value of 'no' has
# no effect.

Warning: Truncating oversized request fieldメッセージを表示しない
ReallyQuiet    yes

# Your own site gives most referrals

自サイト内からのアクセスはアクセス元として表示しない
HideReferrer   kajuhome.com/


webalizerのアクセス設定ファイル変更
# vi /etc/httpd/conf.d/webalizer.conf
#
# This configuration file maps the webalizer log analysis
# results (generated daily) into the URL space.  By default
# these results are only accessible from the local host.
#
Alias /usage /var/www/usage

<Location /usage>
    Order deny,allow
    Deny from all
    Allow from all
    Allow from ::1
    # Allow from .example.com
</Location>

apacheの再起動
【FC1 から Fedora15 / CentOS4 / CentOS5 / CentOS6 の場合】
# /etc/rc.d/init.d/httpd restart

【Fedora16以降 の場合】
# systemctl restart httpd.service


webalizerの実行スクリプト作成
# vi webalizer.sh
#!/bin/sh
/root/jconvertlog.pl /var/log/httpd/access_log > /var/log/httpd/jaccess_log
/usr/bin/webalizer

パーミッション変更(実行権付与)
# chmod 700 webalizer.sh

webalizerの実行
# ./webalizer.sh

実行時のエラー
# ./webalizer.sh
Can't locate Jcode.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8/usr/lib/perl5/site_perl/5.8.7
 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl
 /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8/usr/lib/perl5/vendor_perl/5.8.7
 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl
 /usr/lib/perl5/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/5.8.8 .) at /root/jconvertlog.pl line 2.
BEGIN failed--compilation aborted at /root/jconvertlog.pl line 2.
Complete!

■ Fedora系の場合

Jcodeパッケージのインストール
# yum -y install perl-Jcode
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for perl-Jcode to pack into transaction set.
perl-Jcode-2.06-1.fc6.noa 100% |=========================| 4.0 kB    00:00
---> Package perl-Jcode.noarch 0:2.06-1.fc6 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 perl-Jcode              noarch     2.06-1.fc6       extras             31 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 31 k
Downloading Packages:
(1/1): perl-Jcode-2.06-1. 100% |=========================|  31 kB    00:01
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: perl-Jcode                   ######################### [1/1]

Installed: perl-Jcode.noarch 0:2.06-1.fc6
Complete!

■ CentOS系の場合

Jcodeパッケージのインストール
# cpan2rpm --install Jcode
  
-- cpan2rpm - Ver: 2.027 --  
Signatures not set up  
Upgrade check  
  
* A newer version of this program is now available. To upgrade  
* enter the following command: /usr/bin/cpan2rpm --upgrade  
  
Fetch: HTTP  
  
-- module: Jcode --  
Found: Jcode-2.06.tar.gz  
At: http://search.cpan.org//CPAN/authors/id/D/DA/DANKOGAI  
Retrieving URL  
Metadata retrieval  
Tarball extraction: [/usr/src/redhat/SOURCES/Jcode-2.06.tar.gz]  
Generating spec file  
SPEC: /usr/src/redhat/SPECS/Jcode.spec  
                :  
                :  
                :  
実行中(--clean): /bin/sh -e /var/tmp/rpm-tmp.86916  
+ umask 022  
+ cd /usr/src/redhat/BUILD  
+ rm -rf Jcode-2.06  
+ exit 0  
RPM: /usr/src/redhat/RPMS/i386/perl-Jcode-2.06-1.i386.rpm  
SRPM: /usr/src/redhat/SRPMS/perl-Jcode-2.06-1.src.rpm  
Installing package  
準備中...                   ########################################### [100%]  
   1:perl-Jcode             ########################################### [100%]  
-- Done --

■ webalizerの動作確認

クライアントより[http://サーバのアドレス/usage/]でアクセスして下記の様な画面が表示されれば動作しています。

■ コンテンツ関連

■ その他

ページ先頭へ

Copyright(©)2004-2018 First home server construction. All Right Reserved.