有沒有發現很多的網頁都有一個小小的計數器呢?
目前最有名的計數器套件大概是 wwwcounter 這一套!就我所知的套件最新應該是 wwwcount2.6 版的樣子,不知道有沒有最新的....。


1.  下載與解壓縮:

     # cd /usr/local
     # tar
 -zxvf wwwcount2.6.tar.gz
     # cd
 wwwcount2.6
2. 
修改 /usr/local/wwwcount2.6/builb
     #vi
build
       --with-cgi-bin-dir[=DIR]     designated directory for CGI programs,
                                        default is
/var/www/cgi-bin
      上面的路徑與你的 apache 預設的 cgi-bin 的目錄有關!

       --prefix=dir                 counter base directory, default is
                                       
/usr/local/etc/Counter
 
     這是 wwwcount 安裝的目錄,我都喜歡安裝在 /usr/local 底下,所以設定成上面的目錄。

3. 
修改 /usr/local/wwwcount2.6/Config.tmpl
     #vi Config.tmpl

     CGIBIN_DIR="/var/www/cgi-bin"
     BASE_DIR="/usr/local/etc/Counter"
     CONFIG_FILE="count.cfg"                    計數器設定檔的檔名
     CONFIG_DIR="/usr/local/etc/Counter/conf" 
計數器設定檔存放的位置
     DIGIT_DIR="/usr/local/etc/Counter/digits"   數字圖檔存放的位置
     DATA_DIR="/usr/local/etc/Counter/data"     計數器
     DATABASE_DIR="/usr/local/etc/Counter/db"
     COUNT_DATABASE="Countdb"
     AUTH_DATABASE="Authdb"
     DB_LOCKFILE="Count.lck"
     TT_FONT_DIR="/usr/local/etc/Counter/fonts"
     LOG_DIR="/usr/local/etc/Counter/logs"
     ERROR_LOG_FILE="error.log"
     VISITOR_LOG_FILE="visitor.log"
     RGB_FILE="./data/rgb.txt"
     RGB_DIR="/usr/local/etc/Counter"
     RGB_DATABASE="/usr/local/etc/Counter/db/rgbdb"

4.  修改 /usr/local/wwwcount2.6/count.cfg
     #vi count.cfg

       [options]
       auto_file_creation=Yes   檔案自動建立
       strict_mode=No          嚴格模式
       allow_rgb_database=Yes 允許xx資料庫
       count_reload=No    計算_重載入
       log_error_messages=No log錯誤訊息
       log_visitor_info=Yes  log參觀者資訊
       log_rotation_interval=2592000 log循環間隔(時間)...我猜是log檔案每隔重新建立30天(2592000秒=30天),
       如果要測你可改少一點比如說1天=86400
       show_error_messages_to_browsers=Yes 秀錯誤訊息給瀏覽器

      [authorized]
     
www.kmseh.gov.tw     WEB-Server 的主機名稱
      www
      203.64.152.2              WEB-Server 所使用的IP
      localhost

5. 
編譯可執行檔!
    # ./build --with-cgi-bin-dir=/var/www/cgi-bin --without-database
    # ./build --install

    *** You are installing Counter as root ***


-------------------------------------------------------------------------
Your configuration is shown below. You are only allowed to change the
cgi-bin directory. If you want to change it, edit the file Config.tmpl
and change the variable CGIBIN_DIR to the appropriate directory. Do not change
anything else.

cgi-bin directory       = /var/www/cgi-bin
conf directory          = /usr/local/etc/Counter/conf
conf file to install    = count.cfg
digit directory         = /usr/local/etc/Counter/digits
data directory          = /usr/local/etc/Counter/data
database directory      = /usr/local/etc/Counter/db
Counter database        = Countdb
Auth database           = Authdb     (you have to edit with editdb)
TrueType font directory = /usr/local/etc/Counter/fonts
Sample TrueType font    = ./data/fonts/trebuc.ttf
Log directory           = /usr/local/etc/Counter/logs
Error log file          = error.log
Visitor log file        = visitor.log
RGB file to install     = ./data/rgb.txt

-------------------------------------------------------------------------
Press Control-C to abort
Continue [y|n]?  
<== 看看你的設定正不正確,對的話就開始安裝吧! 

proceeding...

    Now if you know what user and group id child processes of http
    server use, I can change the ownership and access permission
    accordigly. If you do not know, they are usually defined in the
    file httpd.conf with User and Group. I suggest create a unique
    user and group say httpd and set the User and Group to httpd.

*Do you know the user and group id of httpd' child process [y|n]:? y
你知不知道 apache 的使用者名稱與群組!若以 OpenBsd 預設的
apache 來安裝 WWW 的話,那麼預設的名稱為 www
*Enter user id of httpd's child process [no default]:? www
*Enter group id of httpd's child process [no default]:? www

上面兩個都需要視你的設定而變,如果你不知道的話,
那麼進入 httpd.conf 檔案中,去找一下相關的設定就 OK 了!

6.  變更檔案權限:
#chown www:www /var/www/cgi-bin/Count.cgi
#chown -R www:www /usr/local/etc/Counter/data