Zhigang Wang
  • Home
  • Blog
  • Wiki
  • LDP
  • Planet

TWiki安装配置指南

Last modified on 2009-12-01 Tags twiki

在选择和比较了众多Wiki系统之后,最后锁定了TWiki。该系统的主要优点:

  1. 界面美观:在所有的Wiki系统中算的上比较“花哨”,当然没有办法跟一些CMS和Blog系统相比。
  2. 权限管理:本来打算完全使用Wiki系统搭建网站,所以完善的权限管理是必不可少的。
  3. 社区支持:TWiki有一个很活跃的开发社区,并且有很多大公司在内部部署该系统,后续的升级和功能增强不需要担心。

通过部署和实验,发现TWiki的不足:

  1. TWiki 4.0(Dakar Release)在增加了众多新功能的同时,性能较前几个版本出现了下降。大部分TWiki的部署是在公司内部,对性能的要求少一些,但是要在Internet作为发表工具,却是不得不考虑的。本站本来打算使用TWiki搭建,但是由于性能问题,转而使用Drupal,仅将其作为一个子系统。
  2. 强大一般会与复杂同行,TWiki系统亦不能避免。自己在TWiki上面的确花费了一些时间才将其各方面搞清楚(当然可能是自己太菜 :) )。

每个人使用Wiki系统的目的不同,所以对于各系统的好坏自有评判。本人搭建该系统是得到了不少网友的帮助,也参考了许多很好的网上中文资料。尤其感谢车东,他不但翻译了TWiki,让大家有很好的中文系统可用,还写了一篇很好的安装指南。

下面我就将自己搭建本站Wiki系统的过程记录一下,希望对后面使用该系统的朋友有所帮助。下面的操作使用TWiki 4.0.2 在Redhat Enterprise Linux 4 update 3 系统上配置通过,本人使用的个人帐户是zhigang,如果你想在自己的计算机上实验,要考虑到版本和用户之间的不同。

  1. 下载TWiki-4.0.4 和 hotfix-4.0.4-2,解压到 /home/zhigang/wiki.os-drive.com:
  2.  $ unzip TWiki-4.0.4.zip -d ~/wiki.os-drive.com
     $ tar xvzf hotfix-4.0.4-2.tgz -C ~/wiki.os-drive.com
    
    下载CGI-Session-4.03,并安装:
     $ tar xvzf CGI-Session-4.03.tar.gz
     $ cd CGI-Session-4.03
     $ perl Makefile.PL LIB=~/wiki.os-drive.com/lib
     $ make
     $ make test
     $ make install
    
    注:这样的目录布局是为了与自己将来在虚拟主机上的保持一致。
  3. 转换到root用户,或者使用sudo,修改/etc/httpd/conf/httpd.conf,至少修改如下行:
  4. <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    DocumentRoot "/home/zhigang/wiki.os-drive.com"
    User zhigang
    Group zhigang
    
    然后重新启动httpd:
     # service httpd restart
    
  5. 为你的计算机增加别名,在/etc/hosts文件中增加如下行:
  6. 219.236.29.11 wiki.os-drive.com
    
    记着将我的实验机的IP换成你自己的。这样在浏览器的地址栏中输入 http://wiki.os-drive.com 看到的不是我的Wiki系统,而是你本机的实验系统了。这也是为了模拟一个与将来部署几乎相同的环境。
  7. 对TWiki系统各目录的访问权限进行定制:
  8.  $ cd ~/wiki.os-drive.com
     $ cp root-htaccess.txt .htaccess
     $ cp bin/.htaccess.txt bin/.htaccess
     $ cp subdir-htaccess.txt tools/.htaccess
     $ cp subdir-htaccess.txt templates/.htaccess
     $ cp subdir-htaccess.txt locale/.htaccess
     $ cp subdir-htaccess.txt lib/.htaccess
     $ cp subdir-htaccess.txt data/.htaccess
    
    对跟目录下的.htaccess进行修改如下,将对index.html的访问重定向:
     $ diff root-htaccess.txt .htaccess
    13c13
    < # Redirect /urlpath/to/twiki/index.html http://your.domain.com/urlpath/to/twiki/bin/view
    ---
    > Redirect /index.html http://wiki.os-drive.com/bin/view
    
    对bin/.htaccess进行修改如下:
     $ diff bin/.htaccess.txt bin/.htaccess
    41c41
    < AuthUserFile {DataDir}/.htpasswd
    ---
    > AuthUserFile /home/zhigang/wiki.os-drive.com/data/.htpasswd
    66c66
    < ErrorDocument 401 {ScriptUrlPath}/view/TWiki/TWikiRegistration
    ---
    > ErrorDocument 401 /bin/view/TWiki/TWikiRegistration
    81,82c81,82
    <       Allow from 127.0.0.1, 192.168.1.10
    <       Require user {Administrators}
    ---
    >       # Allow from 127.0.0.1, 192.168.1.10
    >       Require user zhigang
    94,97c94,96
    <
    < <FilesMatch "(attach|edit|manage|rename|save|upload|mail|logon|.*auth).*">
    <        require valid-user
    < </FilesMatch>
    ---
    > #<FilesMatch "(attach|edit|manage|rename|save|upload|mail|logon|.*auth).*">
    > #       require valid-user
    > #</FilesMatch>
    
    上面的:
    > AuthUserFile /home/zhigang/wiki.os-drive.com/data/.htpasswd
    
    表示用户认证的文件(即存放用户名和秘密的文件)是/home/zhigang/wiki.os-drive.com/data/.htpasswd;
    >       Require user zhigang
    
    表示要对configure脚本进行访问,需要认证的用户名是zhigang。现在用户认证文件并不存在,需要我们自己创建:
     $ htpasswd -c data/.htpasswd zhigang
    New password: [ your password ]
    Re-type new password: [ your password ]
    Adding password for user zhigang
    
  9. 对TWiki缺省配置进行修改,首先对bin/LocalLib.cfg进行修改:
  10.  $ cp bin/LocalLib.cfg.txt bin/LocalLib.cfg
     $ vi bin/LocalLib.cfg (对其进行修改)
     $ diff bin/LocalLib.cfg.txt bin/LocalLib.cfg
    22c22
    < $twikiLibPath = "/absolute/path/to/your/lib";
    ---
    > $twikiLibPath = "/home/zhigang/wiki.os-drive.com/lib";
    
    再对lib/LocalLib.cfg进行修改:
     $ cp lib/LocalLib.cfg.txt lib/LocalLib.cfg
     $ chmod 600 LocalSite.cfg
    
    这时你需要将浏览器指向: http://wiki.os-drive.com/bin/configure ,并对里面的选项进行修改,然后保存。浏览器会提示你输入用户名和密码,就是刚才设置的。下面是我修改后保存的结果修改的部分:
     $ diff lib/LocalSite.cfg.txt lib/LocalSite.cfg
    1,55c1,78
    < # Example site-specific configuration file for TWiki, held in 'lib' directory.
    < #
    < # This is distributed as LocalSite.cfg.txt - if for some reason you can't,
    < # or don't want to, use =configure= to manage your site configuration, you can
    < # copy this file to LocalSite.cfg edit it manually.
    < #
    < # LocalSite.cfg overrides TWiki.cfg, so there is no risk of your settings
    < # being overwritten when you upgrade.
    < #
    < # Only the most commonly used settings are listed in LocalSite.cfg.txt
    < # See TWiki.cfg to copy across the other (seldom changed) settings
    < #
    < # Use 'LocalLib.cfg' in the 'bin' directory to configure non-standard
    < # locations for the 'lib' directory or Perl modules.
    < #
    <
    < # NOTE: If your server is running Microsoft Windows, paths should
    < # normally be written as "c:/foo" not "c:\foo" (which doesn't do what
    < # you may think it does). You can use '\' without problems inside
    < # single quotes, e.g. 'c:\foo'.
    <
    < # If LocalSite.cfg is used (and it _should_ be), then _all_ the
    < # following paths muct be defined.
    <
    < # URL for TWiki host e.g. http://myhost.com:123
    < $TWiki::cfg{DefaultUrlHost} = 'http://your.domain.com';
    <
    < # cgi-bin URL path for TWiki e.g. /twiki/bin
    < $TWiki::cfg{ScriptUrlPath} = '/twiki/bin';
    <
    < # Attachments URL path e.g. /twiki/pub
    < $TWiki::cfg{PubUrlPath} = '/twiki/pub';
    <
    < # Attachments store file path (not URL), must match /twiki/pub e.g.
    < # /usr/local/twiki/pub
    < $TWiki::cfg{PubDir} = '/home/httpd/twiki/pub';
    <
    < # SECURITY NOTE: Directories =twiki/data= , =twiki/templates= and all their
    < # subdirectories should be set so that they are _not_ visible through
    < # URLs. (Alternatively, move the directories to a place where they are
    < # not visible, and set the paths here as appropriate)
    <
    < # Template directory e.g. /usr/local/twiki/templates
    < $TWiki::cfg{TemplateDir} = '/home/httpd/twiki/templates';
    <
    < # Topic files store (file path not URL) e.g. /usr/local/twiki/data
    < # TWiki will use this path to base other defaults, such as the location
    < # of password files.
    < $TWiki::cfg{DataDir} = '/home/httpd/twiki/data';
    <
    < # TWiki.cfg will use this path to default where to put log files, unless
    < # you override individual paths here.
    < $TWiki::cfg{LogDir} = $TWiki::cfg{DataDir};
    <
    < 1;
    ---
    > # Example site-specific configuration file for TWiki, held in 'lib' directory.
    > #
    > # This is distributed as LocalSite.cfg.txt - if for some reason you can't,
    > # or don't want to, use =configure= to manage your site configuration, you can
    > # copy this file to LocalSite.cfg edit it manually.
    > #
    > # LocalSite.cfg overrides TWiki.cfg, so there is no risk of your settings
    > # being overwritten when you upgrade.
    > #
    > # Only the most commonly used settings are listed in LocalSite.cfg.txt
    > # See TWiki.cfg to copy across the other (seldom changed) settings
    > #
    > # Use 'LocalLib.cfg' in the 'bin' directory to configure non-standard
    > # locations for the 'lib' directory or Perl modules.
    > #
    >
    > # NOTE: If your server is running Microsoft Windows, paths should
    > # normally be written as "c:/foo" not "c:\foo" (which doesn't do what
    > # you may think it does). You can use '\' without problems inside
    > # single quotes, e.g. 'c:\foo'.
    >
    > # If LocalSite.cfg is used (and it _should_ be), then _all_ the
    > # following paths muct be defined.
    >
    > # URL for TWiki host e.g. http://myhost.com:123
    > $TWiki::cfg{DefaultUrlHost} = 'http://wiki.os-drive.com';
    >
    > # cgi-bin URL path for TWiki e.g. /twiki/bin
    > $TWiki::cfg{ScriptUrlPath} = '/bin';
    >
    > # Attachments URL path e.g. /twiki/pub
    > $TWiki::cfg{PubUrlPath} = '/pub';
    >
    > # Attachments store file path (not URL), must match /twiki/pub e.g.
    > # /usr/local/twiki/pub
    > $TWiki::cfg{PubDir} = '/home/zhigang/wiki.os-drive.com/pub';
    >
    > # SECURITY NOTE: Directories =twiki/data= , =twiki/templates= and all their
    > # subdirectories should be set so that they are _not_ visible through
    > # URLs. (Alternatively, move the directories to a place where they are
    > # not visible, and set the paths here as appropriate)
    >
    > # Template directory e.g. /usr/local/twiki/templates
    > $TWiki::cfg{TemplateDir} = '/home/zhigang/wiki.os-drive.com/templates';
    >
    > # Topic files store (file path not URL) e.g. /usr/local/twiki/data
    > # TWiki will use this path to base other defaults, such as the location
    > # of password files.
    > $TWiki::cfg{DataDir} = '/home/zhigang/wiki.os-drive.com/data';
    >
    > # TWiki.cfg will use this path to default where to put log files, unless
    > # you override individual paths here.
    > $TWiki::cfg{LogDir} = $TWiki::cfg{DataDir};
    > $TWiki::cfg{Languages}{fr}{Enabled} = 0;
    > $TWiki::cfg{Languages}{pl}{Enabled} = 0;
    > $TWiki::cfg{Site}{Lang} = 'zh';
    > $TWiki::cfg{DisplayTimeValues} = 'servertime';
    > $TWiki::cfg{Languages}{da}{Enabled} = 0;
    > $TWiki::cfg{Languages}{de}{Enabled} = 0;
    > $TWiki::cfg{Languages}{'zh-tw'}{Enabled} = 0;
    > $TWiki::cfg{UserInterfaceInternationalisation} = 1;
    > $TWiki::cfg{Site}{Locale} = 'zh_CN.UTF-8';
    > $TWiki::cfg{Password} = 'XXXXXXXXXXXX';
    > $TWiki::cfg{Languages}{es}{Enabled} = 0;
    > $TWiki::cfg{Languages}{pt}{Enabled} = 0;
    > $TWiki::cfg{UseLocale} = 1;
    > $TWiki::cfg{LocalesDir} = '/home/zhigang/wiki.os-drive.com/locale';
    > $TWiki::cfg{Languages}{sv}{Enabled} = 0;
    > $TWiki::cfg{Languages}{it}{Enabled} = 0;
    > $TWiki::cfg{Languages}{nl}{Enabled} = 0;
    > $TWiki::cfg{Site}{FullLang} = 'zh-cn';
    > $TWiki::cfg{Site}{CharSet} = 'UTF-8';
    > $TWiki::cfg{LoginManager} = 'TWiki::Client::TemplateLogin';
    > $TWiki::cfg{Register}{AllowLoginName} = 1;
    > $TWiki::cfg{Plugins}{WysiwygPlugin}{Enabled} = 1;
    > $TWiki::cfg{Plugins}{RenderListPlugin}{Enabled} = 1;
    > $TWiki::cfg{Plugins}{EmptyPlugin}{Enabled} = 1;
    > 1;
    

这样一个TWiki的初始配置就算完成了。当然如果你想要它正常工作,还需要启动sendmail:

# service sendmail start
注:Redhat Enterprise Linux 4 中sendmail的缺省配置是没有SMTP认证的,所以别人可以随便使用你的sendmail来转发邮件,一不小心就会成为别人的垃圾邮件转发站。如果没有时间学习sendmail的配置(像我 :) ),可以只在测试TWiki某些功能(如用户注册、布告等)时才启动该服务。

TWiki中的目录管理,权限管理等都角其他Wiki系统复杂一些,但是也强大很多,能够满足很多人的需求。如果有时间,将自己的一些经验一并分享给大家。

参考资料

  1. TWiki协作平台的官方网站。
  2. 车东的TWiki DakarRelease安装备忘。
  3. STL 中文站,一个完全使用TWiki系统搭建的网站,里面有几篇篇介绍TWiki安装的很好文章。
  4. 本站使用的虚拟空间提供商DreamHost。
     

    Feeds

    AtomAll contents
    AtomEnglish contents
    Atom中文内容

    Tags

    gtd syslog twiki virtualizaion wiki xen

    Copyright © 2010 Zhigang Wang. Some right reserved.

    The views expressed on this web site are my own and do not necessarily reflect the views of Oracle.