AWStats 7.3インストール

AWStats 7.3をインストールしてみた。

インストール

  1. portsに入っていたので、それをさっくり。

    # sudo portmaster www/awstats

設定

  1. Web公開用のプログラムが/usr/local/www/awstats以下に作成されるので、必要に応じて移動する。

  2. awstats/toolsの下にあるコンフィグ用のスクリプトを起動する。(入力行を強調表示。)

    # sudo perl awstats_configure.pl
    
    ----- AWStats awstats_configure 1.0 (build 20140126) (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/etc/apache(13/22)/httpd.confExample: /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):
    > /usr/local/etc/apache22/extra/httpd-vhosts.conf
    
    -----> Check and complete web server config file '/usr/local/etc/apache22/extra/httpd-vhosts.conf'
    Warning: You Apache config file contains directives to write 'common' log files
    This means that some features can't work (os, browsers and keywords detection).
    Do you want me to setup Apache to write 'combined' log files [y/N] ? y
    &nbsp; Add '<Directory>' directive
    &nbsp; AWStats directives added to Apache config file.
    
    -----> Update model config file '/usr/local/www/awstats/cgi-bin/awstats.model.conf'
    &nbsp; 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
    
    -----> 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:
    > my.own.domain
    
    -----> 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):
    > /usr/local/etc/awstats
    
    -----> Create config file '/usr/local/etc/awstats/awstats.my.own.domain.conf'
    &nbsp;Config file /usr/local/etc/awstats/awstats.my.own.domain.conf created.
    
    -----> Don't forget to restart manually your web server
    
    -----> 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/local/www/awstats/cgi-bin/awstats.pl -update -config=my.own.domain
    Or if you have several config files and prefer having only one command:
    /usr/local/www/awstats/tools/awstats_updateall.pl now
    Press ENTER to continue...
    
    
    A SIMPLE config file has been created: /usr/local/etc/awstats/awstats.my.own.domain.conf
    You should have a look inside to check and change manually main parameters.
    You can then manually update your statistics for 'my.own.domain' with command:
    > perl awstats.pl -update -config=my.own.domain
    You can also read your statistics for 'my.own.domain' with URL:
    > http://localhost/awstats/awstats.pl?config=my.own.domain
    
    Press ENTER to finish...
    
    #
    

    このスクリプトが完了すると、次の変更がされている。

    • httpd.conf (自分の場合はhttpd-vhosts.confを指定) にawstatsのDirectoryディレクティブを追加
    • httpd.confで指定しているログ形式がcommonの場合にはcombinedに変更
    • /usr/local/etc/awstats/awstats.my.own.domain.conf作成
  3. cgi-binのディレクトリ名を変更しておく。(好みの問題。)

    # mv cgi-bin awstats
  4. awstats.my.own.domain.confを編集し、次の箇所を適切に書き換える。

    • SiteDomain: 解析対象のドメイン名
    • HostAliases: 解析対象のドメイン名のエイリアス名
    • LogFile: 解析するApacheログファイルのフルパス
    • DataDir: 解析結果を保存するディレクトリのフルパス

    Apache以外のログ、またはFTPサーバなどWebサーバ以外のログを解析する場合には、LogTypeとLogFormatも適切に変更。

  5. 登録したいサイトが複数ある場合には、/usr/local/etc/awstatsの下にconfファイルをコピーし、編集して必要な個所を変更する。

  6. tools/awstats_updateall.plを編集し、$DIRCONFIGの行を編集する。

    my $DIRCONFIG = "/usr/local/etc/awstats"
  7. tools/awstats_updateall.plをcgi-binの下にコピーする。

  8. awstats_updateall.plを実行してレポートを作成する。

    # perl awstats_updateall.pl now
  9. awstats_buildstaticpages.plを実行して静的ファイルを作成する。

    # perl awstats_buildstaticpages.pl -lang=jp -config=my.own.domain -awstatsprog=/usr/local/www/awstats/cgi-bin/awstats.pl
  10. cron登録する。

    # sudo crontab -e

    次の行を追加。

    0 2 * * * /usr/local/bin/perl /usr/local/www/awstats/cgi-bin/awstats_updateall.pl now
    0 2 * * * /usr/local/bin/perl awstats_buildstaticpages.pl -lang=jp -config=my.own.domain -awstatsprog=/usr/local/www/awstats/cgi-bin/awstats.pl

これでレポートファイルが作成される。