Plan:
/etc/svn -> SVN 相關設定檔
/etc/svn/account -> SVN 用戶的帳號密碼檔
/etc/svn/authz -> SVN 用戶的權限檔
/home/svn -> SVN 檔案庫的根目錄
/home/trac -> Trac 專案的根目錄
svn -> /home/svn 的 owner
svn -> /home/svn 的 group
www-data -> /home/trac 的 owner
www-data -> /home/trac 的 group
192.168.1.100 -> SVN 及 Trac 伺服器的 IP
svn+ssh://192.168.1.100/svn -> 存取 SVN 的 URL
http://192.168.1.100/trac -> 存取 Trac 的 URL
先產生 /etc/svn 及相關檔案
sudo mkdir -p /etc/svn
sudo touch /etc/svn/account
sudo touch /etc/svn/authz
sudo chown -R www-data /etc/svn
安裝 SVN 版本管理系統
sudo aptitude install subversion
新增 svn user/group
sudo adduser svn
開始用 SVN,先變身成 svn 使用者
su - svn
建立一個 SVN 檔案庫 project1
svnadmin create project1
設定 SVN 檔案庫 project1 的存取權限
chmod -R g+w project1
修改 /home/svn/project1/conf/svnserve.conf, 關閉匿名存取
[general]
anon-access = none
auth-access = write
匯入第一版至檔案庫 project1
svn import /tmp/src-code/ svn+ssh://svn@192.168.1.100/home/svn/project1
自檔案庫 project1 取出
svn co svn+ssh://svn@192.168.1.100/home/svn/project1 src-code-co
安裝 trac
sudo aptitude install trac
安裝 apache2 的 wsgi 模組
sudo aptitude install libapache2-mod-wsgi
設定 apache2 使用 wsgi 模組,將下面區段加到 /etc/apache2/sites-available/default 的最後一行之前
<VirtualHost>
...
...
...
WSGIScriptAlias /trac /var/www/trac/cgi-bin/trac.wsgi
<Directory /var/www/trac>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
trac.wsgi 內容如下
import sys
sys.stdout = sys.stderr
import os
os.environ['TRAC_ENV_PARENT_DIR'] = '/home/trac'
os.environ['PYTHON_EGG_CACHE'] = '/var/www/trac/eggs'
import trac.web.main
application = trac.web.main.dispatch_request
安裝 trac plugin
# SvnAuthzAdmin
sudo easy_install http://trac-hacks.org/svn/svnauthzadminplugin/0.11/
# The AccountManager
sudo easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk/
# IniAdmin
sudo easy_install http://trac-hacks.org/svn/iniadminplugin/0.11/
# TracWysiwygPlugin - for better Wiki editing
sudo easy_install http://trac-hacks.org/svn/tracwysiwygplugin/0.11/
開始用 Trac
建立 project1 的 trac 目錄
sudo mkdir -p /home/trac/project1
初始化 project1 的 trac 目錄
sudo trac-admin /home/trac/project1 initenv
回答下面的問題
Project Name [My Project]> project1
Database connection string [sqlite:db/trac.db]> ENTER
Repository type [svn]> ENTER
Path to repository [/path/to/repos]> /home/svn/project1
Templates directory [/usr/share/trac/templates]> ENTER
完成後會產生 project1 的 trac 設定檔 /home/trac/project1/conf/trac.ini
修改 project1 的 trac 設定檔 /home/trac/project1/conf/trac.ini,將下面這個區段加到檔尾。
[components]修改 [trac] 區塊中的
# SvnAuthzAdmin
svnauthz.* = enabled
[svnauthzadmin]
show_all_repos = true
#啟用 AccountManager 外掛程式
acct_mgr.api.accountmanager = enabled
acct_mgr.web_ui.RegistrationModule = disabled
acct_mgr.htfile.HtPasswdStore = enabled
#關閉預設的 Http 登入認證方式,改用 AccountManager 的登入認證
trac.web.auth.LoginModule = disabled
acct_mgr.web_ui.LoginModule = enabled
#啟用帳號管理
acct_mgr.admin.AccountManagerAdminPage = enabled
#允許用戶變更密碼、刪除帳號
acct_mgr.web_ui.AccountModule = enabled
[account-manager]
password_format = htpasswd
password_file = /etc/svn/account
password_store = HtPasswdStore
#iniadminplugin
iniadmin.iniadmin.iniadminplugin = enabled
#tracwysiwygplugin
tracwysiwyg.* = enabled
authz_file = /etc/svn/authz
autoz_module_name = project1
default_charset = utf-8
存檔離開
Trac 用戶管理
新增 admin 管理員權限
sudo trac-admin /home/trac/project1 permission add admin TRAC_ADMIN
移除匿名者權限
sudo trac-admin /home/trac/project1 permission remove anonymous '*'
新增 project1 群組權限,方便往後新增 member
sudo trac-admin /home/trac/project1 permission add @project1 LOG_VIEW FILE_VIEW WIKI_VIEW WIKI_CREATE WIKI_MODIFY SEARCH_VIEW REPORT_VIEW REPORT_SQL_VIEW
sudo trac-admin /home/trac/project1 permission add @project1 TICKET_VIEW TICKET_CREATE TICKET_MODIFY BROWSER_VIEW TIMELINE_VIEW CHANGESET_VIEW ROADMAP_VIEW MILESTONE_VIEW
變更 /home/trac 的存取權限,讓 apache 可以存取它
sudo chown -R www-data.www-data /home/trac
新增 member
System Part
sudo adduser [new_member]
sudo adduser [new_member] svn
Trac Part
login as admin
Admin->Accounts->Users->Add Account:
->Username:[new_member];Password:[xxxxxx];Confirm password:[xxxxxx]
->Add
Admin->Subversion->Subversion Access->Subversion Paths->/
->Add Path Member to /
->subject:[new_member]; Read:v; Write:v
->Add
Admin->Subversion->Subversion Access->Subversion Paths->/home/svn/[project_name]
->Add Path Member to /home/svn/[project_name]
->subject:[new_member]; Read:v; Write:v
->Add
Admin->general->Permissions
->Add subject to Group:
->Subject:[new_member]; Group:@[project_name]
->Add
備份 project1 的 SVN 檔案庫(/home/svn/project1)
svnadmin dump /home/svn/project1 > /tmp/project1-svn.dump
還原 project1 SVN 檔案庫
svnadmin create --fs-type fsfs /home/svn/project1
svnadmin load /home/svn/project1 < /tmp/project1-svn.dump chown -R svn.svn /home/svn/project1
備份 Trac (/home/trac/project1)
trac-admin /home/trac/project1 hotcopy /tmp/project1-trac-backup
還原 Trac(/home/trac/project1)
cp /tmp/project1-trac-backup /home/trac/project1
參考資料:
SVN + Trac + Apache 完整安裝攻略
http://www.vixual.net/blog/archives/232
沒有留言:
張貼留言