[DICT.TW] DICT.TW 線上字典

DICT@FreeBSD 架設程序


Chienwen, DICT.TW

2006.02.07
update:2007.03.29
update:2014.04.19

    安裝前準備:

  1. 你必須熟悉如何使用電腦,包括如何開機與關機。

  2. 你己經安裝好 FreeBSD,並且 ports tree 已更新完畢。

  3. 你己經安裝好 Apache http server,並可執行 cgi 程式。


  4. 安裝概念:

  5. 若你要加設一個如同 DICT.TW 線上字典 的網站,你必須安裝三種程式:

    • Dict Protocol (RFC 2229) server (以及 Dictd words database)
      提供 DICT 的伺服程式;當然也須加上字典資料庫。

    • Dict Protocol (RFC 2229) client
      查詢 DICT 的客戶端程式。

    • WWW Frontends for DICT Servers
      網站前端程式,透過 WWW 執行 client 呼叫 server 的查詢動作,並傳回結果。


  6. 安裝 DICT:

  7. 由 ports 安裝 DICT:

    # cd /usr/ports/net/dictd ; make install
    # cd /usr/ports/net/dictd-database ; make install
    # cd /usr/ports/chinese/dictd-database ; make install
    # cd /usr/ports/textproc/dict ; make install


  8. 編輯 CONF 檔案:

  9. 修改 /usr/local/etc/dictd.conf,加入這些設定:

    database moecomp   { data "/usr/local/lib/dict/moecomp.dict.dz"
                         index "/usr/local/lib/dict/moecomp.index" }
    database netterm   { data "/usr/local/lib/dict/netterm.dict.dz"
                         index "/usr/local/lib/dict/netterm.index" }
    database pydict    { data "/usr/local/lib/dict/pydict.dict.dz"
                         index "/usr/local/lib/dict/pydict.index" }
    database cedict    { data "/usr/local/lib/dict/cedict.dict.dz"
                         index "/usr/local/lib/dict/cedict.index" }

    database web1913   { data "/usr/local/lib/dict/web1913.dict.dz"
                         index "/usr/local/lib/dict/web1913.index" }
    database wn        { data "/usr/local/lib/dict/wn.dict.dz"
                         index "/usr/local/lib/dict/wn.index" }
    database gazetteer { data "/usr/local/lib/dict/gazetteer.dict.dz"
                         index "/usr/local/lib/dict/gazetteer.index" }
    database jargon    { data "/usr/local/lib/dict/jargon.dict.dz"
                         index "/usr/local/lib/dict/jargon.index" }
    database foldoc    { data "/usr/local/lib/dict/foldoc.dict.dz"
                         index "/usr/local/lib/dict/foldoc.index" }
    database elements  { data "/usr/local/lib/dict/elements.dict.dz"
                         index "/usr/local/lib/dict/elements.index" }
    database easton    { data "/usr/local/lib/dict/easton.dict.dz"
                         index "/usr/local/lib/dict/easton.index" }
    database hitchcock { data "/usr/local/lib/dict/hitchcock.dict.dz"
                         index "/usr/local/lib/dict/hitchcock.index" }
    database vera      { data "/usr/local/lib/dict/vera.dict.dz"
                         index "/usr/local/lib/dict/vera.index" }
    database devils    { data "/usr/local/lib/dict/devils.dict.dz"
                         index "/usr/local/lib/dict/devils.index" }
    database world95   { data "/usr/local/lib/dict/world95.dict.dz"
                         index "/usr/local/lib/dict/world95.index" }

  10. 修改 /usr/local/etc/dict.conf,加入這一行:

    server dict.tw

    (請將 dict.tw 置換為你的域名)


  11. 啟動 DICT:

  12. 設定開機時,自動啟動 DICT,在 /etc/rc.conf 加入這些設定:

    # DICT
    dictd_enable="YES"
    dictd_flags="--locale zh_TW.UTF-8"

  13. 若有更改 DICT 設定,則須重新啟動 dictd:

    # /usr/local/etc/rc.d/dictd restart


  14. 安裝網站前端程式:

  15. 下載 WWW Frontends 程式 (Dict CGI interface by Doug Hoffman),到 Apache 網頁根目錄 index.pl:

    http://dict.tw/pub/Dict

  16. 修改 WWW Frontends 程式:

    • 第 206、216 行,原是:
      $name = substr($_, 2, 10);
      改為
      $name = substr($_, 1, 10);
    • 第 208、218 行,原是:
      $desc = substr($_, 13);
      改為
      $desc = substr($_, 12);
    • 第 517 行:
      <head>
      之後,插入一行
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    • 第 57~83 行,變數設定,請依自己網站設定值更正。

      範例:
      # ---------- Configuration variables

      $Debug = 0;
      $Pgm = "index.pl"; # 修正,程式名稱
      #$hostUrl = "http://www.dict.org";
      $hostUrl = "http://$host"; # 修正
      $cgiPath = "$hostUrl"; # 修正
      $ReturnUrl = "$cgiPath/$Pgm";
      $bin = "/data/httpd/html/bin"; # 無用

      $CRInfo = "$ReturnUrl?Form=$Pgm".
          "1&Query=00-database-info&Strategy=*&Database=*";
      $SInfo = "$ReturnUrl?Form=$Pgm". "4";

      $Dict = "/usr/local/bin/dict -h localhost";
      $DictAlt = "/usr/local/bin/dict -h dega.cs.unc.edu";
      $Counter = "/usr/local/etc/Counter/data/$Pgm.dat";
      $Count = "$cgiPath/Count.cgi";
      $Background = ""; # 網頁背景
      $Heading1 = "DICT.TW 線上字典"; # 視窗標題
      $Heading2 = "<a href=\"http://www.dict.org/\">The DICT Development Group</a>: Online&nbsp;Dictionary&nbsp;Query";
      $Counter1 = "<img src=\"$Count?sh=0|df=$Pgm.dat\" alt=\"\">";
      $Counter2 = "<img src=\"$Count?sh=0|df=total.dat\" alt=\"\">";
      # $Counter1 = "";
      # $Counter2 = "";
      $WebMaster = "<a href=\"http://dict.tw/about.htm\#webmaster\">網站管理員</a>"; # 修正

  17. 設定 WWW Frontends 檔案屬性:

    # chmod 755 index.pl

    (設定 cgi 程式可執行)


  18. 使用瀏覽器:

  19. 你現在可以連結這個網頁查詢字彙了!若要自建字典資料庫,請參考: DICT@FreeBSD 字典資料庫編譯程序



DICT.TW
線上字典