1. 安裝 Python
- Trac使用python語言編寫,自然需要這個環境
我安裝的是python-2.7.1.msi,官方的打不開,我是在網上搜尋的這個安裝檔案
所選安裝目錄是D:\Trac\Python27
2. 安裝資料庫
If you're using Python 2.5 or 2.6, you already have everything you need.
2. 安裝 Python Setupfile
- Python的更新檔包,提供包管理工具
我安裝的是setuptools-0.6c11.win32-py2.7.exe,官方的打不開,我是在網上搜尋的這個安裝檔案。
安裝的時候它會自己找到Python安裝目錄,按預設安裝即可。在這裡會生成非常有用的腳本easy-install,會為之後的安裝提供很多友善。
3. 安裝 Genshi,可以用下面的指令用 Setupfile 來安裝
-ClearSilver是一套快速、強大、語言無關的html模闆系統,在Trac0.11版本中被Genshi取代。Genshi是ClearSilver HTML模闆引擎
安裝步驟:
1). 打開cmd
2). 進入含有easy_install的目錄,我的在Python27\Scripts\
3). 執行easy_install Genshi
4. 安裝Trac語言包
easy_install Babel==0.9.5
5. 安裝Trac
essy_install Trac
6. 配置Trac環境
1). 通過 trac-admin 建立一個 Trac Environment
trac-admin d:\trac\mytest initenv
2). 運作成功後,即可以開啟 Trac 服務
指令行執行: tracd --port 8000 D:\Trac\mytest
在網頁上打開http://127.0.0.1:8000/便可以進入所建工程,但是沒有賬戶登入管理
其它機器也可以通過通路這台機器的 IP 加端口來通路這個服務。最基本、最簡單的使用,可以不用 Apache 來搭建 Web 伺服器。
3). 添加使用者
添加使用者名為Admin,密碼為 root的賬戶
python trac-digest.py -u Admin -p root >> D:\Trac\mytest\conf\digest.txt
用使用者登入方式啟動這個服務
tracd --port 8000 --auth=mytest,D:\Trac\mytest\conf\trac.htdigest,trac D:\Trac\mytest
注意: trac-digest.py這個檔案是不存在的,可以在網上去拷貝或下載下傳一個.
參考網站:
http://rain.snowrain.org/archives/73
http://trac.edgewall.org/wiki/TracStandalone#GeneratingPasswordsWithoutApache
4). Trac 管理者密碼的設定
單純把某個使用者添加到了工程裡,并不能讓這個使用者有管理工程的權限,是以,需要單獨配置設定權限給這個使用者:比如說,我要分本給 Admin 這個使用者管理者權限,可以用下面的語句:
> trac-admin D:\Trac\mytest permission add admin TRAC_ADMIN
用tracd重新開機服務: tracd --port 8000 --auth=mytest,D:\Trac\mytest\conf\trac.htdigest,trac D:\Trac\mytest
好了,Trac算是基本搭建好了,區域網路裡的使用者都可以通路通過IP+端口通路這個Trac站點了。如果你要通過Apache伺服器來提供網頁版服務,在網頁上注冊使用者等功能,你還需要下面的步驟:
7. 根據提示沒有找到web界面的logo來修改trac.ini
[header_logo]
alt = (please configure the [header_logo] section in trac.ini)
height = -1
link =
src = common/trac_banner.png
width = -1
8. 安裝賬戶管理插件
1). 下載下傳Account Manager Plugin插件
http://trac-hacks.org/wiki/AccountManagerPlugin
2). 安裝插件
easy_install https://trac-hacks.org/svn/accountmanagerplugin/0.11
或者:源碼安裝方法
(1). python setup.py bdist_egg 生成目标檔案xx.egg, 像Eclipse的插件jar。源碼裡面有setup.py檔案
(2). easy_install xx.egg 将為所有的項目安裝此插件;如果隻為某個項目,可以直接把egg檔案拷到項目的plugins目錄裡。
3). 配置trac.ini檔案來啟動插件
由于不清楚需要啟動哪一項,我啟動了所有關于acct_mgr的元件
[account-manager]
account_changes_notify_addresses =
authentication_url =
force_passwd_change = true
hash_method = HtDigestHashMethod
htdigest_realm = trac
htpasswd_hash_type = crypt
notify_actions = new,change,delete
password_file = D:\Trac\mytest\conf\trac.htdigest
password_format = htdigest
password_store = HtDigestStore
persistent_sessions = False
refresh_passwd = False
user_lock_max_time = 0
verify_email = true
[components]
acct_mgr.* = enabled
4). 安裝webadmin
我用的源碼安裝
同樣要在trac.ini配置為開啟模式
[components]
acct_mgr.* = enabled
webadmin.* = enabled
9. 配置郵件伺服器
[notification]
admit_domains =
always_notify_owner = false
always_notify_reporter = false
always_notify_updater = true
ambiguous_char_width = single
email_sender = SmtpEmailSender
ignore_domains =
mime_encoding = none
sendmail_path = sendmail
smtp_always_bcc =
smtp_always_cc = [email protected]
smtp_default_domain =
smtp_enabled = true
smtp_from [email protected]
smtp_from_name =
smtp_password = 123
smtp_port = 25
smtp_replyto = [email protected]
smtp_server = smtp.163.com
smtp_subject_prefix = __default__
smtp_user = [email protected]
ticket_subject_template = $prefix #$ticket.id: $summary
use_public_cc = False
use_short_addr = false
use_tls = false
10. 關聯Git
1). 安裝git插件
D:\Trac\Python27\Scripts>easy_install http://github.com/hvr/trac-git-plugin/tarball/master
2). 配置git
[components]
acct_mgr.* = enabled
webadmin.* = enabled
tracopt.versioncontrol.git.* = enabled
tracext.git.* = enabled
tracopt.ticket.commit_updater.* = enabled
[trac]
...
## let Trac cache meta-data via CachedRepository wrapper; default: false
cached_repository = true
## disable automatic garbage collection for in-memory commit-tree cache; default: false
persistent_cache = true
## length revision sha-sums should be tried to be abbreviated to (must be >= 4 and <= 40); default: 7
shortrev_len = 6
## minimum length for which hex-strings will be interpreted as commit ids in wiki context; default: 40
wiki_shortrev_len = 7
## executable file name (in case of doubt use absolute path!) of git binary; default: 'git'
git_bin = C:\msysgit\msysgit\bin\git.exe
## define charset encoding of paths stored within git repository; default: 'utf-8'
git_fs_encoding = latin1
## enable reverse mapping of git email addresses to trac user ids; default: false
trac_user_rlookup = true
## use git-committer id instead of git-author id as changeset owner; default: true
use_committer_id = false
## use git-committer timestamp instead of git-author timestamp as changeset time; default: true
use_committer_time = false
11. Ticket中責任人變更為下拉菜單方式
修改trac.ini檔案
[ticket]
...
restrict_owner = true
12. 修改Trac中附件大小
修改trac.ini檔案
[attachment]
max_size = 262144
TIP:
1. Web伺服器,在支援CGI或FastCGI的Web伺服器上,Trac可以通過腳本和接口作為一個CGI來運作。還可以使用Apache伺服器,但需要安裝mod_python或mod_wsgi。以上的Web伺服器部署方式,可能對大部分人都太複雜,是以Trac内置了一個單獨運作的Web伺服器,Tracd。在Trac官方的文檔中說,Tracd是一個輕量級的、獨立的Trac web伺服器,在大多數情況下,它比CGI腳本更容易安裝,并且更快。在本文中,我将使用Tracd作為Web伺服器。(我不懂CGI和Apache,Tracd拯救了我,這個小東東對我完全夠用了)