Windows 下安装 Trac,并配置使用Mercurial hg

安装 python2.6 。
http://pypi.python.org/pypi/setuptools/ 下载安装 setuptools 。
执行下面的命令安装 Trac 。

easy_install –always-unzip Trac

现在 Trac 已经安装完毕了,该安装 Mercurial hg 插件了。

http://mercurial.selenic.com/wiki/Download 下载 Mercurial hg 的源代码,并执行setup.py install 来安装(python 2.5 需要 Visual Studio 2005来编译,python 2.6 需要Visual Studio 2008来编译。按官方的说明也可以使用官方发布的Windows二进制版本)。还要注意 Mercurial hg 需要是0.9.5以上版本。
用svn 取出 http://svn.edgewall.com/repos/trac/sandbox/mercurial-plugin-0.11(地址已修改为 http://svn.edgewall.org/repos/trac/plugins/0.11/mercurial-plugin) 目录,并执行 setup.py install 来安装 Trac 的 hg 插件。

现在环境意见建立完毕,开始建立项目了。

执行下面的命令建立 Trac 项目。

trac-admin D:\项目路径 initenv

执行中会提示版本控制系统的类型,直接输入hg就可以。接着会询问版本库的位置,直接输入绝对路径就可以。最后向 D:\项目路径\conf\trac.ini 文件添加以下内容来启用 Mercurial hg 插件。

[trac]
repository_type = hg
repository_dir = /path/to/my/hg/repository

[hg]
# — Show revision number in addition to the changeset hash
show_rev = yes

# — Changeset hash format
node_format = short
# hex: Show the full SHA1 hash
# short: Show a shortened hash for the changesets

现在项目已经建立,可以执行下面的命令来运行项目。然后就可以访问 http://127.0.0.1:8000 来查看项目了。

tracd –port 8000 D:\项目路径

汉化 wiki 。
取出 http://trac-hacks.org/svn/zoomquiettranslation/trunk/0.11.x,并执行以下命令。

trac-admin D:\项目路径 wiki load default-pages/

然后将 ZhTracGuideToc.py 文件拷到 D:\项目路径\plugins 目录下。最后向 D:\项目路径\conf\trac.ini 增加以下内容。

[mainnav]
wiki.href = /wiki/ZhWikiStart

[metanav]
help.href = /wiki/ZhTracGuide

好了,现在就汉化完毕了。

默认Trac没有任何帐号,需要运行下面的命令增加帐号并赋予其全部权限。

>htpasswd -c 项目路径\conf\.htpasswd gamexg 密码
>trac-admin 项目路径 permission add gamexg TRAC_ADMIN

现在 gamexg 用户已经拥有和全部权限,可以使用下面的命令启动 Trac 了。

tracd –hostname=localhost -p 8000 –basic-auth=项目名称,项目路径\conf\.htpasswd,项目名称 项目路径

例子:

tracd -s –basic-auth=trac,trac/conf/.htpasswd, –port 8000 trac

PS:使用中发现utf8文件中文显示有问题。从网上查了一下资料,发现为项目配置文件(项目目录\conf\trac.ini)设置以下内容就可以解决中文utf8文件乱码的问题。

default_charset=utf-8

如果有混合编码可以参考这里TRAC中文显示乱码再解决,为不同的文件设置不同的编码。

[mimeviewer]
#mime_map=text/plain; charset=gbk:c:txt:TXT,
mime_map=text/x-php; charset=utf-8:php
tab_width=4

参考:
Trac Install
http://trac.edgewall.org/wiki/TracInstall
Trac Mercurial
http://trac.edgewall.org/wiki/TracMercurial#TracBrowserchangesin0.11
Trac+subversion拥有强大的bug管理能力
http://www.uml.org.cn/pzgl/200909258.asp

  WordPress › 错误