アクセスログ解析ツールAWStatsのインストールと設定。
Fedora Core 5の場合は、yumリポジトリにAWStatsのパッケージが存在するため、yumを使ってインストールする。
# インストールされているか確認 rpm -qi subversion # インストールされていなければ、インストール yum -y install awstats
AWStatsに付属するスクリプトを使って、設定ファイルを作成する。
cd /usr/share/awstats/tools/ ./awstats_configure.pl
以下、メッセージに従って必要事項を入力する。
----- AWStats awstats_configure 1.0 (build 1.6) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Apacheの設定ファイルのパスを設定する。 このファイルに、AWStatsを使用する上で必要な設定が自動的に書き込まれる。
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf' Add 'Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"' Add 'Alias /awstatscss "/usr/share/awstats/wwwroot/css/"' Add 'Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"' Add 'ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"' Add '<Directory>' directive AWStats directives added to Apache config file. -----> Update model config file '/etc/awstats/awstats.model.conf' File awstats.model.conf updated. -----> Need to create a new config file ? Do you want me to build a new AWStats config/profile file (required if first install) [y/N] ? y ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
新しい設定ファイルを作るかどうか。 後でここで作成した設定ファイルをベースにして編集するので、yを入力して設定ファイルを作成する。
-----> Define config file name to create What is the name of your web site or profile analysis ? Example: www.mysite.com Example: demo Your web site, virtual server or profile name: > invisiblefulmoon.net ~~~~~~~~~~~~~~~~~~~~~~~
ログ解析を行う対象のドメイン名を入力する。 バーチャルドメインを使用している場合は、そのドメイン名を入力する。
-----> Define config file path In which directory do you plan to store your config file(s) ? Default: /etc/awstats Directory path to store config file(s) (Enter for default): > ~~~~
設定ファイルを作成する場所を入力する。 デフォルトのパス(/etc/awstats)でよければ、何も入力せずにEnterを押す。
-----> Create config file '/etc/awstats/awstats.invisiblefulmoon.net.conf' Config file /etc/awstats/awstats.invisiblefulmoon.net.conf created. -----> Restart Web server with '/sbin/service httpd restart' httpd を停止中: [ OK ] httpd を起動中: [ OK ]
Apacheの設定ファイルにAWStatsの設定が書き込まれたあと、自動的に再起動される。 もし再起動中にエラーになった場合は、設定ファイルに追記された内容を確認して修正する必要がある。
-----> Add update process inside a scheduler Sorry, configure.pl does not support automatic add to cron yet. You can do it manually by adding the following command to your cron: /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=invisiblefulmoon.net Or if you have several config files and prefer having only one command: /usr/share/awstats/tools/awstats_updateall.pl now Press ENTER to continue...
cronにログ集計用のスケジュールを登録しようとしたが失敗したため、手動で設定する必要がある旨が表示されている。 ここで他に出来ることはないので、Enterキーを押すだけ。 後で手動でcronに登録する必要がある。
A SIMPLE config file has been created: /etc/awstats/awstats.invisiblefulmoon.net.conf You should have a look inside to check and change manually main parameters. You can then manually update your statistics for 'invisiblefulmoon.net' with command: > perl awstats.pl -update -config=invisiblefulmoon.net You can also read your statistics for 'invisiblefulmoon.net' with URL: > http://localhost/awstats/awstats.pl?config=invisiblefulmoon.net Press ENTER to finish...
ここまでで設定ファイルの作成が完了。 Enterキーを押してスクリプトを終了する。
作成したデフォルトの設定ファイルを元にして、Apacheのアクセスログ解析用の設定ファイルを作成する。 ここでは、アクセスログを解析する対象ドメインにwww.invisiblefulmoon.netを指定した場合の例として設定ファイルを作成する。
cd /etc/awstats cp awstats.invisiblefulmoon.net.conf awstats.www.invisiblefulmoon.net.conf
作成した設定ファイルの下記の値を変更する。 変更する箇所は、ログファイル名、ドメイン名、ホストのエイリアス名。
[変更前] LogFile="/var/log/httpd/access_log" SiteDomain="invisiblefulmoon.net" HostAliases="invisiblefulmoon.net 127.0.0.1 localhost" [変更後] LogFile="/var/log/httpd/www.access_log" SiteDomain="www.invisiblefulmoon.net" HostAliases="www.invisiblefulmoon.net 127.0.0.1 localhost"
必要に応じて、下記の値も変更する
設定ファイルを作成したら、解析を行う。 解析を行うと、DirDataに解析結果が作成され、ブラウザで解析結果を見ることが出来るようになる。
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=www.invisiblefulmoon.net
解析が成功したら、ブラウザで「http://localhost/awstats/awstats.pl?config=www.invisiblefulmoon.net」を開く。 するとHTMLに整形された解析結果を見ることが出来る。
作成したデフォルトの設定ファイルを元にして、Postfixのアクセスログ解析用の設定ファイルを作成する。 ここでは、アクセスログを解析する対象ドメインにmail.invisiblefulmoon.netを指定した場合の例として設定ファイルを作成する。
cd /etc/awstats cp awstats.invisiblefulmoon.net.conf awstats.mail.invisiblefulmoon.net.conf
作成した設定ファイルの下記の値を変更する。
[変更前] LogFile="/var/log/httpd/access_log" LogType=W LogFormat=1 SiteDomain="invisiblefulmoon.net" HostAliases="invisiblefulmoon.net 127.0.0.1 localhost" [変更後] LogFile="perl /usr/share/awstats/tools/maillogconvert.pl standard < /var/log/maillog |" LogType=M LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd" SiteDomain="mail.invisiblefulmoon.net" HostAliases="mail.invisiblefulmoon.net 127.0.0.1 localhost"
また、解析内容・表示形式をメールログにあわせた形にするため、下記の値(Level〜、Show〜)も変更する。
LevelForBrowsersDetection=0 LevelForOSDetection=0 LevelForRefererAnalyze=0 LevelForRobotsDetection=0 LevelForSearchEnginesDetection=0 LevelForKeywordsDetection=0 LevelForFileTypesDetection=0 : : ShowMonthStats=UHB ShowDaysOfMonthStats=HB ShowDaysOfWeekStats=HB ShowHoursStats=HB ShowDomainsStats=0 ShowHostsStats=HBL ShowRobotsStats=0 ShowEMailSenders=HBML ShowEMailReceivers=HBML ShowSessionsStats=0 ShowPagesStats=0 ShowFileTypesStats=0 ShowOSStats=0 ShowBrowsersStats=0 ShowOriginStats=0 ShowKeyphrasesStats=0 ShowKeywordsStats=0 ShowMiscStats=0 ShowHTTPErrorsStats=0 ShowSMTPErrorsStats=1
設定ファイルを作成したら、Apacheの例と同様に解析を行う。
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=mail.invisiblefulmoon.net