14. カウンタ (wwwcount) 設定

 自分でホームページを持つと、気になるのがアクセスカウントです。
 wwwcount は、お手軽にカウンターを設置できる、便利なツールです。
 実数は把握していませんが、PC-UNIX 系のサイトでは、ほとんどこれを利用していると思われます。
14.1 ports を手に入れる
14.2 カウンタの設定方法
14.3 おまけ 時刻、日付の表示方法

14.1 ports を手に入れる

 ports を手に入れます。
wwwcount → /usr/ports/www/wwwcount/
にあります。
 makemake install はいつもと同じです。
 ただし、make のときに何故か、wwwcount は、CheckSum ファイルというのがないので、エラーになってしまいます。
 そのときは、
> make NO_CHECKSUM=yes
 と、打ってください。そうすると、CheckSum ファイルなしでもインストールできます。

 しばらくすると
    Welcome to the configuration procedure of Count 2.5
    ---------------------------------------------------

    o You must know where your system keeps CGI programs (cgi-bin directory)
      It is necessary to generate the install program.
      This directory must exist. If this directory does not exist, the
      configuration procedure will Abort!

    o You have to decide a directory, where you will keep all counter related
      stuff. This directory will have other directories inside. Default
      values will be supplied, press Return key to accept the default value.

      Try to Accept the default value, it will make your life much easier,
      because not much error checking is done to verify input.

    During installation, the directories will be created for you
    if they do not exist and if you have the permission to do so.
    ++
Continue [y|n]?
 これは「あなたのシステムには、cgi 用のディレクトリはありますか?」とか「あなたはディレクトリを作る特権を持っていますか?」などと聞いてきているようです。
 FreeBSD4.0 以上であれば、デフォルトで perl も CGI 用のディレクトリも用意されていますので、root 権限でこの操作を行っている限り心配ありません。
 「y」で答えましょう。

 次に
    You need to enter the full path of the directory where you system
    keeps the CGI programs.

*cgi-bin directory [/usr/local/www/cgi-bin]:
 と聞いてきます。「あなたの CGI 用のディレクトリのフルパスは、/usr/local/www/cgi-bin ですか?」と聞いています。特別な設定をしていない限り、Apache のインストール時点で、/usr/local/www/cgi-bin が作られていますので、そのまま [Enter] キーを入力します。

 次は
    You need to enter the base directory of the counter related stuff.
    It must be a absolute path.

*Base directory [/usr/local/etc/Counter]:
 と聞いてきます。「カウンタ用のベースディレクトリを /usr/local/etc/Counter に作ってもよいか?」という意味なので、特別なことをするつもりがなければ、そのまま [Enter] キーを入力します。

 次は、
    You need to enter the name directory of the configuration file.

* Config directory [/usr/local/etc/Counter/conf]:
 「コンフィグレーションファイル用ディレクトリを /usr/local/etc/Counter/conf に作ってもよいか?」と聞いてきます。これも [Enter] キーを入力しましょう。

 次は、
    You need to enter the name of the configuration file. Note, it
    is not the path of the file, just the name. No / is allowed in the
    name.
    This file contains the information about

        o if you want to ignore access from certain hosts
        o host access authentication

    You will create this file later by running the program "Gen_conf".

* Name of the configuration file [count.cfg]:
 「コンフィグレーションファイルを count.cfg という名前で作ってもよいか?」と聞いてきます。これも [Enter] キーを入力しましょう。

 次は、
    You need to enter the directory of the counter data file.

*Data directory [/usr/local/etc/Counter/data]:
 「カウンタ用のディレクトリとして /usr/local/etc/Counter/data を作ってもよいか?」と聞いてきます。これまた [Enter] キー入力です。

 次は、
    You need to enter the directory of digits

*Digits directory [/usr/local/lib/Counter/digits]:
 「カウンタ用のデジタル文字を /usr/local/etc/Counter/digits というディレクトリに作ってもよいか?」と聞いてきます。これまた [Enter] キー入力です。

 次は、
    You need to enter the directory of the Log file.

*Log directory [/var/log]:
 「カウンタ作成のログファイルを /var/log に作ってもよいか?」と聞いてきます。これまた [Enter] キー入力です。

 次は、
    You need to enter the name of the Log file. Note, it just a name, not
    the path. No / is allowed in the name.
    This file hold the error messages of the counter. It also
    logs if someone tried to access your counter remotely.

* Name of the log file [Counter.log]:
 「カウンタ作成のログファイルを Counter.log という名前で作ってもよいか?」と聞いてきます。これまた [Enter] キー入力です(だいぶ疲れてきましたね、あと一息です)。

 次は、
Your configuration:
----------------------------------------------------------------
CgiBinDir=/usr/local/www/cgi-bin
BaseDir= /usr/local/etc/Counter
DigitDir=/usr/local/lib/Counter/digits
ConfDir= /usr/local/etc/Counter/conf
ConfFile=count.cfg
DataDir=/usr/local/etc/Counter/data
LogDir=/var/log
LogFile=Counter.log
----------------------------------------------------------------
Everything looks OK [y|n]?
 今まで設定してきたことをもう一度再確認のために、見せてくれているわけです。
 問題なければ、「y」で答えましょう。

 次に、
    Welcome to the conf file generation procedure of Count 2.5

    This program creates a workable conf file for your host only, you have
    to edit it by hand if you want to add other hosts. The file will have
    enough comments in it to help you out. You also have to hand edit it
    if you want to use netmasks to mask out a entire network or a specific
    range of hosts in a network.

    First of all you must know your
        1) fully qualified domain name (FQDN), for example,
            if your hostname is foo and your domain name is bar.com,
            then your FQDN is
            foo.bar.com

        2) IP address of your host, for example,
            192.165.155.2

        3) If your host has any nickname defined, for example,
            www.foo.com. Note, th nick name also has to be a FQDN.

Continue [y|n]?
 これは、「コンフィグレーションファイルのデフォルト設定を行うために、正式なドメイン名か IP アドレスを入力しなければならない。もしあなたが別のニックネームをもっているなら(おそらく Virtual Domain のことでしょう)その名前も入力しなければならない」と言っているようです。
 ここまで、サーバ設定ができているなら、間違いなくこれらを知っているはずですから、[y]で答えましょう。

 次は、
    No Error checking will be done with your IP address, therefore,
    you better make sure you are entering the correct IP address.

* Enter your IP address [no default]:
 「あなたの IP アドレスを入力してください」と聞いてきますので、IP アドレスを「xxx.yyy.zzz.2」の形式で入力してください。

 次は、
* Does your host have any nickname [y|n]:?
 と Virtual Domain 名を聞いてきます。なければ、[n]を入力して終わりですし、あれば、[y]を入力して Virtual Domain 名を入力してください。

 次は、
    Now you need to decide if you will allow the users to create datafiles
    for them automatically. If you allow, the counter datafile will be
    created for the user if it does not exist and a pre-determined counter
    number will be inserted to it. If you do not allow, you have to create
    the datafile for each user, provided that the data directory has proper
    write permission.

    Allowing users to create datafile is very convenient, as you do not
    have to be asked all the time when someone decides to use the counter.
    But the dark side of this is, anyone will be able create datafiles in
    the data directory. The decision is yours.

* Do you want to allow automatic file creation [[y|n]
 これ実はわたし、あんまり意味がよくわからないんですがとりあえず「自動的にコンフィグレーションを作ってもよいか?」という気がするので(間違ってたらごめんなさい)[y]を入力しましょう。

 次は、
    Now you need to decide if you want to compile the program in strict
    mode. If you compile the program in strict mode, the browsers which
    do not return the environment variable HTTP_REFERER, will not be
    served, that is no access hit will be recorded, no time or date
    will be displayed. Instead, a string 888888 will be displayed.

    The strict mode ensures that your counter data file can not be messed
    by accessing the counter remotely from a browser which does not return
    that variable. Note, good browsers like netscape returns this
    variable. Other browsers e.g. Mosaic does not return this variable in
    IMG GET method at this time.  This strict mode is experimental at this
    time!

* Do you want the program to run in strict mode [[y|n]
 これもよくわかんないんですよね。「HTTP プロトコルに準拠したアクセスでないとちゃんとしたカウンターを返さないように厳しくチェックしますか?」ってな意味かしら?とりあえずわたしの場合、[y]入力です。  次は、
* Do you want to ignore access hits from your own host [y|n]
 これは、「自分自身のホストがアクセスしたときもカウンタ値をあげますか?」っていう意味ですよね。この辺は、みずからのプライドの問題なので、どちらでもよいでしょう、わたしはずっこいので [y]入力です。

 次は、
    Ok, do you want the users to use the file rgb.txt for color name
    lookup? It is very inefficient to search this file every time the
    web page is loaded. If you answer yes, the color name
    will be looked up and used. If you answer no, the color will be
    looked up but instead of the counter image, the RGB value will
    be displayed and the user will be asked to use the RGB value
    instead. This will prevent users to use this file. However,
    the convenience of allowing to use rgb.txt file is that color name e.g,
    red, gold etc.  can be used instead of cryptic red, green and blue
    components of the color.

* Allow using the rgb.txt file [y|n]?
 これは、「RGB で色指定することを許可するか?」ということですね。まあ、カラフルを好むなら[y]ですね、そのかわり「そうするとちょっと重くなるぞ」と警告してくれますが、たいした差はないとおもいます。[y]でいきましょう。

 次は、
    You can decide if you want to allow reload count in your site.
    When a visitor reloads a page and if you decided to count reload,
    the counter will increment with each reload. It is a good idea
    to ignore reload count as it minimizes remote abuse of the counter.
    Howerver, there may be situation when you will have to count reload,
    for example if visitors are coming through a proxy server. If you
    decide to count reload, your users will have choice to ignore or
    count reload for their counters with "reload=T or F" options.

* Do you want to allow the counter to be reloaded [y|n]?
 これは「リロードするたびにカウンタ値をあげますか?」ってことですね。ホームページで更新するたびにカウンターが上がっていくところを見かけたことはありませんか?あれはこの設定を[y]にしてるんですね。ここを[n]にしておけば同じ IPアドレスから連続で、更新をかけてもカウンタ値はあがりません。ここは、むやみにカウンタ値があがっても安っぽく見られちゃうので[n]にしたいところです。

 次は、
    You can decide if you want to log the counter error messages
    or warning messages to the log file. If you are concerned about disk
    space, answer n to the question.

* Do you want to log error messages [[y|n]?
 これは、「カウンタエラーが発生したら、ログを出力しますか?」ってことですね。[y]を入力しておきましょう。

 次は、
    You can decide if you want to show error messages to the browsers.
    The counter error messages are verbose and may reveal information about
    the system (e.g. full path of the data file or config file) in case of
    error. If you are concerned with privacy or simply don't care to show
    error messages to browsers (you are confident that the counter works
    perfectly), then answer n to the question. If you answer n, then then
    if there is an error or the access is denied, the visitor will see the
    broken image (browser default).

* Do you want to show error messages to browsers [[y|n]?
 これは、「カウンタエラーが発生したら、相手のブラウザにもお知らせしますか?」ってことですね。[y]を入力しておきましょう。

 それで、やっと
    Created conf file "count.cfg"
    Please look at it, you might want to edit it!
 というのが出力されて make の終わりです。
 count.cfg は、後で編集できるので、今までのところで少し間違っていても大丈夫です。
 あとは、make install でインストール終了です。

14.2 カウンタの設置方法

 では、インストールしたカウンタをどのようにして設置するかについて説明しましょう。
 *.html の中に次のように記述します。
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat">
 仮名の部分には、ホームページのタイトル名となるような英数字をいれてください。それがカウンタ用ファイル名として 仮名.dat が自動的につくられます。気をつけないといけないのは、WEB サーバ内に複数のホームページを置いているときには、ファイル名がダブらないようにすることです。全然関係のないページ同士で知らないうちにカウンタ値がどんどんあがっていくことになってしまいます。

 カウンタのフォントとして、5つのフォントが用意されています。上に指示したのは、A タイプでデフォルトは、A タイプになっているわけです。これを違うフォントで表示するには以下のように記述します。
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&dd=B">
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&dd=C">
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&dd=D">
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&dd=E">
 フレームをなくしたり、大きくしたり、色を変えたりもできます。
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&ft=0">
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&ft=ピクセル数">
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&frgb=FF0000">
 frgb= で指定するのは、000000 が黒 FFFFFF が白となる、RGB 指定です。

 カウンタの数字の色を変えるには、
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&prgb=FF0000">
 prgb= で指定するのは、frgb= で指定したものと同じ方法です。

 カウンタを 1000ずつカンマで区切るには、
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&comma=T">
 なのですが、1000 以下だとわかりませんね。桁数を設定するには、
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&md=10">
 md=1010 のところが桁数の指定になるわけです。  デフォルトでは、6桁に設定されているのですが、実際のカウンタ値の桁数に自動調整させるには、
<IMG SRC="/cgi-bin/Count.cgi?df=仮名.dat&pad=0">
 と指定します。他に &sh;=Fと指定するとカウンタを表示することなく、カウントアップさせることが出来ます。

14.3 おまけ 時刻、日付の表示方法

 wwwcount には、おまけの機能として、時刻を表示する機能があります。
<IMG SRC="/cgi-bin/Count.cgi?display=clock">
 24時間表示にするには
<IMG SRC="/cgi-bin/Count.cgi?display=clock&tformat=24">
 日付を表示するには
<IMG SRC="/cgi-bin/Count.cgi?display=date">
 これだと、西洋式の mm-dd-yyyy ですね。
 これを日本式の yyyy-mm-dd とするには
<IMG SRC="/cgi-bin/Count.cgi?display=date&dformat=YYYYMMDD">
 とすることになります。

 まあ、あまり時刻表示やカウンタ表示は、必要以上に多用しないことをお勧めします。必要以上に多用するとこのページのように重くなっちゃいます(笑)。


戻る