TWiki安装配置指南
Last modified on 2009-12-01 Tags twiki在选择和比较了众多Wiki系统之后,最后锁定了TWiki。该系统的主要优点:
- 界面美观:在所有的Wiki系统中算的上比较“花哨”,当然没有办法跟一些CMS和Blog系统相比。
- 权限管理:本来打算完全使用Wiki系统搭建网站,所以完善的权限管理是必不可少的。
- 社区支持:TWiki有一个很活跃的开发社区,并且有很多大公司在内部部署该系统,后续的升级和功能增强不需要担心。
通过部署和实验,发现TWiki的不足:
- TWiki 4.0(DakarRelease)在增加了众多新功能的同时,性能较前几个版本出现了下降。大部分TWiki的部署是在公司内部,对性能的要求少一些,但是要在Internet作为发表工具,却是不得不考虑的。本站本来打算使用TWiki搭建,但是由于性能问题,转而使用Drupal,仅将其作为一个子系统。
- 强大一般会与复杂同行,TWiki系统亦不能避免。自己在TWiki上面的确花费了一些时间才将其各方面搞清楚(当然可能是自己太菜:) )。
每个人使用Wiki系统的目的不同,所以对于各系统的好坏自有评判。本人搭建该系统是得到了不少网友的帮助,也参考了许多很好的网上中文资料。尤其感谢车东,他不但翻译了TWiki,让大家有很好的中文系统可用,还写了一篇很好的安装指南。
下面我就将自己搭建本站Wiki系统的过程记录一下,希望对后面使用该系统的朋友有所帮助。下面的操作使用TWiki 4.0.2在Redhat Enterprise Linux 4 update 3系统上配置通过,本人使用的个人帐户是zhigang,如果你想在自己的计算机上实验,要考虑到版本和用户之间的不同。
- 下载TWiki-4.0.4 和 hotfix-4.0.4-2,解压到/home/zhigang/wiki.os-drive.com:
$ 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
注:这样的目录布局是为了与自己将来在虚拟主机上的保持一致。- 转换到root用户,或者使用sudo,修改/etc/httpd/conf/httpd.conf,至少修改如下行:
<Directory /> Options FollowSymLinks AllowOverride All</Directory>DocumentRoot "/home/zhigang/wiki.os-drive.com"User zhigangGroup zhigang
然后重新启动httpd:# service httpd restart
- 为你的计算机增加别名,在/etc/hosts文件中增加如下行:
219.236.29.11 wiki.os-drive.com
记着将我的实验机的IP换成你自己的。这样在浏览器的地址栏中输入 http://wiki.os-drive.com看到的不是我的Wiki系统,而是你本机的实验系统了。这也是为了模拟一个与将来部署几乎相同的环境。- 对TWiki系统各目录的访问权限进行定制:
$ 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 .htaccess13c13< # 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/.htaccess41c41< AuthUserFile {DataDir}/.htpasswd---> AuthUserFile /home/zhigang/wiki.os-drive.com/data/.htpasswd66c66< ErrorDocument 401 {ScriptUrlPath}/view/TWiki/TWikiRegistration---> ErrorDocument 401 /bin/view/TWiki/TWikiRegistration81,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 zhigang94,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 zhigangNew password: [ your password ]Re-type new password: [ your password ]Adding password for user zhigang
- 对TWiki缺省配置进行修改,首先对bin/LocalLib.cfg进行修改:
$ cp bin/LocalLib.cfg.txt bin/LocalLib.cfg $ vi bin/LocalLib.cfg (对其进行修改) $ diff bin/LocalLib.cfg.txt bin/LocalLib.cfg22c22< $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.cfg1,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.&