Trac + SVN 的搭配非常方便, 也是一直沒從 SVN 轉換到 Git 的原因之一.
既然想要取代 SVN, Trac + Git 當然也是該要有的, 下面就來將 Trac + Git 完成.
此篇文章假設已經將 Git Server 環境建置完畢, 若尚未建置, 可參考下述:
此篇文章不會詳細解說 Trac 及 額外 Trac 指令等, 有興趣可以參考:
相關資料準備
- Server: project_name.example.com
- Project name: project_name
- Git Repository Path: /var/cache/git (/var/cache/git/prject_name.git)
- Trac Path: /var/lib/trac (/var/lib/trac/prject_name)
- Apache 帳號、密碼檔: /etc/apache2/dav_git.passwd
- Trac 存取帳號: test_user
安裝步驟
- # on Debian / Ubuntu Linux
- apt-get install trac libapache2-mod-python
- apt-get install trac-git
設定 Trac、存取權限
- mkdir -p /var/lib/trac/project_name
- trac-admin /var/lib/trac/project_name initenv
Project Name => project_name
Path to repository => /var/cache/git/project_name.git - vim /var/lib/trac/project_name/conf/trac.ini
# 修改
default_charset = iso-8859-15 => default_charset = utf-8
repository_dir = /var/cache/git/project_name.git
repository_type = git
# 於檔案最後面增加
[components]
# for plugin version 0.10 (如果 trac 版本是 0.10, 下面 gitplugin 前的 # 要拿掉)
# gitplugin.* = enabled# for plugin version 0.11.0.1+ (目前 Debian Testing 版 trac 為 0.11, 需要加這段)
tracext.git.* = enabled - chown www-data:www-data -R /var/lib/trac/project_name
- trac-admin /var/lib/trac/project_name permission list # 列出有哪些帳號可以存取
- trac-admin /var/lib/trac/project_name permission remove anonymous '*' # 不允許匿名存取
- trac-admin /var/lib/trac/project_name permission add test_user TRAC_ADMIN # 增加帳號
設定 Apache VirtualHost
- vim /etc/apache2/sites-available/trac_project_name.conf
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/lib/trac/project_name
ServerName project_name.example.com
ErrorLog /var/log/apache2/trac-project_name-error.log
CustomLog /var/log/apache2/trac-project_name-access.log combinedSetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv "/var/lib/trac/project_name"
PythonOption TracUriRoot "/trac/project_name"
<LocationMatch "/trac/[^/]+/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/dav_git.passwd
Require valid-user
</LocationMatch>
</VirtualHost> - ln -s /etc/apache2/sites-available/trac_project_name.conf /etc/apache2/sites-enabled/trac_project_name.conf
- /etc/init.d/apache2 restart
- 瀏覽 http://project_name.example.com/trac/project_name/ 即完成.
問題與解法
- 若 Git 安裝完, 一直說沒有 Git 相關套件的, 可試著安裝 GitPlugin.