Trac 手记(一) : Windows 下安装 Trac

   开发更好的软件,我相信 ITS(Issue Tracking System) 和 VCS(Version Control System) 是必不可少的。对于国内现状,相信大多数本土公司都实施了 SCM ,却看不到 ITS 的痕迹。  
   所以,有必要学习和使用 Trac。

   通过搜索引擎,知道有以下 ITS :
      Bugzilla : 基于 Perl。
      Gemini : 非开源,基于 .Net,免费版可供5人使用, SharpDevelop 就是用的他。
      JIRA : 基于 Java,重量级。
      Mantis : 基于 PHP,轻量级。
      Trac : 基于 Python。

   考虑到一致性和其他各种原因,我选择 Trac。
   本文主要内容就是介绍如何安装和配置 Trac,并与 Apache、Subversion 整合。
 

1) 准备软件
  SVN-1.46 :
    http://subversion.tigris.org/files/documents/15/41077/svn-win32-1.4.6.zip
  SVN-1.46-Py2.5 :
    http://subversion.tigris.org/files/documents/15/41078/svn-win32-1.4.6_py25.zip
  TortoiseSVN-1.4.6 (可选) :
    http://jaist.dl.sourceforge.net/sourceforge/tortoisesvn/TortoiseSVN-1.4.6.11647-win32-svn-1.4.6.msi
  TortoiseSVN-1.4.6-LangPack (可选):
    http://jaist.dl.sourceforge.net/sourceforge/tortoisesvn/LanguagePack-1.4.6.11647-win32-zh_CN.exe

  Apache-2.2.6 :   
    http://apache.mirror.phpchina.com/httpd/binaries/win32/apache_2.2.6-win32-x86-no_ssl.msi
  Python-2.5 :
    http://www.python.org/ftp/python/2.5/python-2.5.msi
  Mod_Python-3.3.1-py2.5-Apache2.2 :
    http://apache.mirror.phpchina.com/httpd/modpython/win/3.3.1/mod_python-3.3.1.win32-py2.5-Apache2.2.exe
  SetupTools-0.6c7
  http://peak.telecommunity.com/dist/ez_setup.py

  PySqlite-2.4.0-py2.5  :
    http://initd.org/pub/software/pysqlite/releases/2.4/2.4.0/pysqlite-2.4.0.win32-py2.5.exe
    https://files.cnblogs.com/zealic/pysqlite-2.4.0.win32-py2.5.rar

  Trac-0.11b :
    http://ftp.edgewall.com/pub/trac/Trac-0.11b1.zip
  Genshi-0.4.4-py2.5 :
    http://ftp.edgewall.com/pub/genshi/Genshi-0.4.4-py2.5.egg

  以上大多软件都有明确的依赖关系,切忌使用最新版本,比如 Mod_Python 依赖 Python-2.5,哪怕是 Python-2.5.1 都不支持。
  将以上所有软件下载到 D:\Setup

                      
2) 配置环境
  2.1) 安装基本环境
   首先安装 Python-2.5,这里假设安装到 D:\Python
   安装 Apache-2.5.6,这里假设安装到 D:\Apache
   安装 Mod_python。
  
  2.2) 配置环境
    在 httpd.conf 末尾加入以下代码:

LoadModule python_module modules/mod_python.so
Alias /hi/ "D:/Apache/htdocs/py_scripts/"
<Directory "D:/Apache/htdocs/py_scripts/">
  AddHandler mod_python .phtm
  PythonHandler test 
  PythonDebug On
</Directory>

    
    创建一个文件 test.py 到 Apache 的 .\htdocs\py_scripts 目录中
[test.py]

from mod_python import apache
def handler(req):
  req.content_type 
= 'text/plain'
  req.write(
"Hello World!")
  
return apache.OK

   2.3) 测试
   启动 Apache 服务。
   访问 http://127.0.0.1:8080/hi/hello.phtm 测试,出现 "Hello World!" 代表成功。
  
   2.4) 安装 pysqlite
        执行 pysqlite-2.4.0.win32-py2.5.exe 以自动安装 pysqlite。

 

3) 安装 Subversion
  这里假设 Subversion 安装到 D:\Subversion
  3.1) 安装 Subversion service
    安装 Subversion 服务,请参考我的 用 BAT 注册 Subversion 服务 以简化安装步骤。
 
  3.2) 安装 Python binding for Subversion
    解压 svn-win32-1.4.6_py25.zip,将 svn 目录和 libsvn 目录复制到 D:\Python\Lib
    修改 libsvn 目录下的 "_*.dll" 文件为 "_*.pyd"

  
  3.3) 与 Apache 整合
     a) 装载模块
        复制 D:\Subversion\bin 目录下的以下文件复制到目录 D:\Apache\dlls
        - intl3_svn.dll
        - libdb44.dll
        - ssleay32.dll
        - libeay32.dll
        - mod_authz_svn.so
        - mod_dav_svn.so


     b) 配置 Apache
      在 httpd.conf 末尾加入以下代码:

LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_svn_module dlls/mod_dav_svn.so
LoadModule authz_svn_module dlls/mod_authz_svn.so
<Location /svn>
  DAV svn
  SVNParentPath "G:\ALM\VersionRepository"
</Location>
# libsvn 依赖下面的两个 dll,如若不导入,则会造成 trac 无法进行 Browser source
LoadFile "./dlls/ssleay32.dll"
LoadFile "./dlls/libeay32.dll"

  3.4) 测试
      关闭 Apache 服务,并重启。
      确保你的 Svn 仓库中存在 MyRepos。
      访问 http://127.0.0.1:8080/svn/MyRepos
      出现 Subversion 你的 MyRepos 仓库的目录结构则代表成功。

 

4) 安装 Trac
  4.1) 安装 Trac
    a) 直接执行 ez_setup.py 以安装 Python SetupTools。

    b) 解压 Trac 到 D:\Setup\Trac-0.11b1
       安装 Trac 依赖包 Genshi-0.4.4-py2.5.egg

D:\Python\Scripts\easy_install D:\Setup\Genshi-0.4.4-py2.5.egg

    c) 安装 Trac

D:\Setup\Trac-0.11b1\setup.py install

    d) 初始化 trac 仓库

D:\Python\Scripts\trac-admin D:\ALM\trac\test initenv

      按照命令提示进行 test 的配置。


  4.2) 与 Apache 整合
    在 Apache 中添加以下代码

<Location /trac>
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv D:\ALM\trac\test
    SetEnv PYTHON_EGG_CACHE /tmp
    PythonOption TracUriRoot /trac
    AuthType None
</Location>

  4.3) 测试
    打开 http://127.0.0.1:8080/trac/browser,检查是否显示 SVN 的目录树。
    出现则代表成功。



5) 安装 TortoiseSVN (可选)
    安装 TSVN 及其语言包。



6) 依赖关系图


图标释义 :
 
星星 : 独立组件。
  灯泡 : 依赖其他独立组件的组件。
  魔法棒 : Apache 模块。
  蓝线为依赖 Subversion。
  橙线为依赖 Python。
  紫线为依赖  Apache。



7) 结束语
  Trac 配置起来很复杂,这里只做了简单的配置,甚至没做任何权限管理。
  这些内容,我们下次再说。

  警告 : 本文所使用的是 Trac 0.11b1 版,不保证对文章内容对其他版本适用。
        同样也不推荐你在实际环境部署使用该beta版,如出现任何问题,概与本人无关。
  如果你存在任何有关问题,请 mail 我 : rszealic{at}gmail.com
 
  版权所有,保留所有权利。



8) 参考资料
The trac official site :
http://trac.edgewall.org/

windows下Apache+SVN+Trac安装及配置(二):
http://luchar.javaeye.com/blog/151051

apache + mod_python 的问题 :
http://bbs.chinaunix.net/thread-806879-1-1.html

Windows下Trac的安装方法 :
http://bbs.phpxe.com/thread-44-1-1.html

Subversion 中文在线手册 :
http://www.subversion.org.cn/svnbook
http://www.subversion.org.cn/svnbook/1.1/svn-ch-9-sect-6.1.html

 

posted on 2007-12-29 13:25  Zealic  阅读(26898)  评论(22编辑  收藏  举报