Install Trac On Your Windows

阅读本文前,请参考前面两篇文章:
SVN服务器的搭建 和 ViewVC的安装
注:由于WordPress的限制,下面有些路径的反斜杠使用正斜杠代替

1. Download & Install trac-0.10.4.win32.exe
2. Download & Install pysqlite-2.3.4.win32-py2.3.exe
3. Download & Install mod_python-3.3.1.win32-py2.3-Apache2.0.exe
4. Download & Install clearsilver-0.9.14.win32-py2.3.exe
5. Download & Install setuptools-0.6c7.win32-py2.3.exe

6. 在httpd.conf中增加配置如下:
 LoadModule python_module modules/mod_python.so 

<Location /trac>
  SetHandler mod_python 
  PythonHandler trac.web.modpython_frontend  
  PythonOption TracEnvParentDir c:/trac  
  PythonOption TracUriRoot /trac  
</Location>

7. C:/>mkdir trac
8. C:/Trac>python c:/Python23/Scripts/trac-admin oa initenv
系统提示如下:
—————————————————————–
Creating a new Trac environment at C:/Trac/oa
Trac will first ask a few questions about your environment in order to initalize and prepare the project database.Please enter the name of your project.This name will be used in page titles and descriptions.

Project Name [My Project]> OA

Please specify the connection string for the database to use. By default, a local SQLite database is created in the environment directory. It is also possible to use an already existing PostgreSQL database (check the Trac documentation for the exact connection string syntax).

Database connection string [sqlite:db/trac.db]>

Please specify the type of version control system, By default, it will be svn. If you don’t want to use Trac with version control integration, choose the default here and don’t specify a repository directory. in the next question.

Repository type [svn]>

Please specify the absolute path to the version control repository, or leave it blank to use Trac without a repository. You can also set the repository location later.

Path to repository [/path/to/repos]> c:/Repo/oa

Please enter location of Trac page templates. Default is the location of the site-wide templates installed with Trac.

Templates directory [C:/Python23/share/trac/templates]>
Creating and Initializing Project Installing default wiki pages
… …
—————————————————————–
9. 权限设置
<LocationMatch “/trac/[^/]+/login”> 
  AuthType Basic 
  AuthName “Trac”
  AuthUserFile c:/Repo/passwd.txt
  Require valid-user
</LocationMatch>

10. 管理

  • 下载WebAdmin

WebAdmin是一个对Trac进行权限控制的插件,安装完成后可以在Trac页面中直接对权限进行控制,其下载地址为http://trac.edgewall.org/wiki/WebAdmin,页面中有许多版本,根据自己需要下载即可(Trac 0.11以后的版本会自动集成WebAdmin,只有0.11之前的版本需要手动下载安装)。

  • 下载后得到一个压缩包,解压得到一个*.egg的文件夹
  • 拷贝刚才解压得到的*.egg文件夹,粘贴到你所要配置的Trac目录下的plugins目录,例如
C:/Trac/oa/plugins
  • 在控制台执行easy_install
C:/Python23/Scripts/easy_install.exe C:/Trac/oa/plugins/TracWebAdmin-0.1.2dev_r4240-py2.3.egg
  • 在Trac.ini文件中加上以下代码:
[components]
webadmin.* = enabled
  • 执行Trac-Admin的Upgrade命令
C:/Trac>python c:/Python23/Scripts/trac-admin update
  • 重启Apache
  • 完成,在控制台中输入

C:/Trac>python c:/Python23/Scripts/trac-admin c:/Trac/oa
Welcome to trac-admin 0.10.4 Interactive Trac administration console.
Copyright (c) 2003-2006 Edgewall Software
Type: ‘?’ or ‘help’ for help on commands.
Trac [c:/Trac/oa]>

即可进行管理,但这里的管理是基于命令行的

也可以:

C:/>python c:/Python23/Scripts/trac-admin c:/Trac/oa permission add charry TRAC_ADMIN

这样的话,就可以用charry这个账户登陆到web页面进行管理了,只是没有命令行的管理界面强大。

ViewVC的安装

步骤如下: 

  • 下载ViewVC,并解压到:C:\viewvc-1.0.4
  • 下载 Python-2.3.5.exe 并安装
  • 下载 pywin32-210.win32-py2.3.exe 并安装
  • 下载 svn-python-1.4.4.win32-py2.3.exe 并安装
  • 在ViewVC的目录下执行 python viewvc-install,会提示:

C:viewvc-1.0.4>python viewvc-install This is the ViewVC 1.0.4 installer. It will allow you to choose the install path for ViewVC. You will now be asked some installation questions. Defaults are given in square bra Just hit [Enter] if a default is okay. Installation path [C:Program Filesviewvc-1.0.4]: C:viewvc-1.0.4 DESTDIR path (generally only used by package maintainers) []:

  • 打开viewvc.conf,修改如下:
    将cvs_roots = cvs: /home/cvsroot注释掉,改为:svn_roots = svn: c:\Repo\oa(这里的oa是我先前建立的Repository),再将 default_root = cvs注释掉.
  • 注意:svn_path最好也要填写,比如:svn_path = C:/Subversion/bin,否则annotate的时候会出错

在apache的httpd.conf加入:

ScriptAlias /codeview/ “C:/viewvc-1.0.4/bin/cgi/” <Directory “C:/viewvc-1.0.4/bin/cgi/”> AllowOverride None Options None Order allow,deny Allow from all </Directory>


加入diff支持

DiffUtils, enscript, libintl, libiconv, sed将他们分别解压,然后保存在 C:/ViewVCUtil下,并将 C:/ViewVCUtil 加入到 %PATH% 中

  • 打开viewvc.conf,将use_enscript = 0改成1,重新启动standalone.py(如果是以apache+DAV的方式运行,则不需要执行standalone.py)
  • 如果遇到

error: (2, ‘CreateProcess’, ‘The system cannot find the file specified.’)

的错误,请检查,C:/ViewVCUtil是否在%PATH%中,如果还是不行,请把C:/ViewVCUtil下的文件copy到C:/Windows/System32下,也可以。