DokuWiki 2009-12-25

Wiki Systemには様々な物がある。 有名な物一覧はWikipediaに記載されているので、そちらを参照のこと。

最も有名なのは恐らくMediaWikiとおもわれるが、昔からあると言うことも考えると、PukiWiki等になるかもしれない。

しかし、どうもあのWikipedia調のシステムは好みではないので、この際、DokuWikiを使うことにした。

DokuWikiはデータをstaticに持つので、事後修正はそれなりに楽だが、逆に一気に変更をかけたいときなどに面倒な部分もある。

情報源となるURLを以下に

ともあれ、最小限のインストールに関するメモを以下に。

DokuWikiのInstall

ここでは、DokuWikiのInstallに関して記述する。

DokuWikiを動かす環境と、DokuWiki自身のインストールを記載する。

基盤環境

DokuWikiが動作する環境は、突き詰めれば、

  • httpd
  • PHP (5以上が望ましい)

が動く環境である。 もちろん、Rewrite問題や画像取り扱いを考えれば様々なApplicationがあることが望ましいが、取りあえずこれで最小限は動く。

というわけで、NetBSD + Lighttpd + PHP5 その他のパッケージの環境でDokuWikiを動かすことにする。 事前に以下のpkgsrcをインストールしておく。全部必要というわけでもないが、後にWordPressを動かすことも考えているので、そのついでと言うこともある。

  • lighttpd-1.4.22
  • ImageMagick
  • mecab
  • perl5
  • php5
  • php-bz2
  • php5-dom
  • php-ftp
  • php-gd
  • php-gettext
  • php-iconv
  • php-json
  • php-mbstring
  • php-pdflib
  • php-posix
  • php-sockets
  • php-xmlrpc
  • php-zip
  • php-zlib

DokuWiki本体のInstall

まず、DokuWikiを設置するディレクトリを決める。

今回は、htdocs/dokuwiki/に設置する物とする。

DokuWiki インストールを参照すること。

  1. ダウンロードページから最新バージョンをダウンロード
  2. セキュリティのページを読む。
  3. tarballを展開する。
    • ファイルを展開すると、dokuwiki-yyyy-mm-ddというディレクトリが出来るので、dokuwikiにリネームする
    • htdocs下にコピーする。
    • permissionを設定する。owner、groupはWeb-Serverの実行UID、GIDにする。今回はwww-data.wwwとする
    • # cd htdocs/dokuwiki
      # chmod -R 775 data/
      # chgrp -R www data/
      # cd data
      # chmod 2775 attic cache index locks media meta pages tmp
      # cd ..
      # chmod 775 conf
      # chgrp www conf
      # cd ../lib
      # chgrp -R www plugins/
      # chmod -R 775 plugins/
      
  4. http://URL/dokuwiki/install.phpにアクセス
    • 必要な情報を投入

これで、DokuWikiが動き出すので、dokuwiki/install.phpを削除する。

日本語対応強化

ここを参照した

  1. MailのEncodeをISO-2022-jpにする
    • 今回、これを導入しなかった。ja=iso2022-jpと言えない現状(個人的にはUTF-8は嫌いだが)があるので。
  2. 検索の日本語化
    1. pkgsrcからMecabを入れる
      • /etc/mk.confにMECAB_CHARSET= utf-8 を忘れずに設定すること
    2. inc/indexer.phpに以下の変更を加える
      • $ diff -c ./indexer.php.orig ./indexer.php
        *** ./indexer.php.orig  Sat Feb  7 21:48:34 2009
        --- ./indexer.php       Sat Feb  7 22:02:14 2009
        ***************
        *** 6,11 ****
        --- 6,15 ----
           * @author     Andreas Gohr <andi@splitbrain.org>
           */
          
        + /* for Japanese index search with Mecab */
        + define ('PRE_TOKENIZER', '/usr/pkg/bin/mecab -O wakati');
        + /* ------------------------------------ */
        + 
          if(!defined('DOKU_INC')) die('meh.');
          require_once(DOKU_INC.'inc/io.php');
          require_once(DOKU_INC.'inc/utf8.php');
        ***************
        *** 55,62 ****
        --- 59,70 ----
              $l = strlen($w);
              // If left alone, all chinese "words" will get put into w3.idx
              // So the "length" of a "word" is faked
        + /* for Japanese index search with Mecab */
        + /*
              if(preg_match('/'.IDX_ASIAN2.'/u',$w))
                  $l += ord($w) - 0xE1;  // Lead bytes from 0xE2-0xEF
        + */
        + /* ------------------------------------ */
              return $l;
          }
          
        ***************
        *** 220,225 ****
        --- 228,257 ----
          
              list($page,$body) = $data;
          
        + /* for Japanese index search with Mecab */
        +     if(function_exists(proc_open) && defined('PRE_TOKENIZER')) {
        +         $dspec = array(
        +             0 => array("pipe", "r"),
        +             1 => array("pipe", "w"),
        +             2 => array("file", "/dev/null", "w")
        +         );
        +         $process = proc_open(PRE_TOKENIZER, $dspec, $pipes);
        +         if(is_resource($process)) {
        +             stream_set_blocking($pipes[0], FALSE);
        +             stream_set_blocking($pipes[1], FALSE);
        +             fwrite($pipes[0], $body . "\n");
        +             fclose($pipes[0]);
        +  
        +             $body = '';
        +             while(!feof($pipes[1])) {
        +                 $body .= fgets($pipes[1], 32768);
        +             }
        +             fclose($pipes[1]);
        +             proc_close($process);
        +         }
        +     }
        + /* ------------------------------------ */
        + 
              $body   = strtr($body, "\r\n\t", '   ');
              $tokens = explode(' ', $body);
              $tokens = array_count_values($tokens);   // count the frequency of each token
        ***************
        *** 489,495 ****
        --- 521,532 ----
                      $wild |= 2;
                      $wlen -= 1;
                  }
        + /* for Japanese index search with Mecab */
        + /*
                  if ($wlen < IDX_MINWORDLENGTH && $wild == 0 && !is_numeric($xword)) continue;
        + */
        +         if (preg_match('/[^0-9A-Za-z]/u', $string) && $wlen < IDX_MINWORDLENGTH && $wild == 0 && !is_numeric($xword)) continue;
        + /* ------------------------------------ */
                  if(!isset($tokens[$xword])){
                      $tokenlength[$wlen][] = $xword;
                  }
        ***************
        *** 628,639 ****
        --- 665,701 ----
           */
          function idx_tokenizer($string,&$stopwords,$wc=false){
              $words = array();
        + /* for Japanese index search with Mecab */
        +     if(function_exists(proc_open) && defined('PRE_TOKENIZER')) {
        +         $dspec = array(
        +             0 => array("pipe", "r"),
        +             1 => array("pipe", "w"),
        +             2 => array("file", "/dev/null", "w")
        +         );
        +         $process = proc_open(PRE_TOKENIZER, $dspec, $pipes);
        +         if(is_resource($process)) {
        +             stream_set_blocking($pipes[0], FALSE);
        +             stream_set_blocking($pipes[1], FALSE);
        +             fwrite($pipes[0], $string . "\n");
        +             fclose($pipes[0]);
        +             $string = '';
        +             while(!feof($pipes[1])) {
        +                 $string .= fgets($pipes[1], 32768);
        +             }
        +             fclose($pipes[1]);
        +             proc_close($process);
        +         }
        +     }
        + /* ------------------------------------ */
              $wc = ($wc) ? '' : $wc = '\*';
          
              if(preg_match('/[^0-9A-Za-z]/u', $string)){
        + /* for Japanese index search with Mecab */
        + /*
                  // handle asian chars as single words (may fail on older PHP version)
                  $asia = @preg_replace('/('.IDX_ASIAN.')/u',' \1 ',$string);
                  if(!is_null($asia)) $string = $asia; //recover from regexp failure
        + */
          
                  $arr = explode(' ', utf8_stripspecials($string,' ','\._\-:'.$wc));
                  foreach ($arr as $w) {
        
serverapp/dokuwiki.txt · 最終更新: 2010/01/07 12:00 by seirios
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0