整合之前文章, 來做快速建置筆記, 如果有看不懂的步驟, 或遇到任何問題, 可以回到原始文件再看看(下述文件會把較可能出問題的地方列出來).
Debian 的建置 通常是放在 /var/lib 下, 所以下述採用的如下:
- svn : /var/lib/svn/repository (通常我喜歡多設一個 repository, 不然 /var/lib/svn 就夠了)
- trac: /var/lib/trac
# subversion + apache2
- apt-get install libapache2-svn apache2 subversion
- mkdir /var/lib/svn/repository
- svnadmin create /var/lib/svn/repository/PROJECT_NAME
- find /var/lib/svn/repository/PROJECT_NAME -type f -exec chmod 660 {} \;
- find /var/lib/svn/repository/PROJECT_NAME -type d -exec chmod 2770 {} \;
- chown -R root.www-data /var/lib/svn/repository/PROJECT_NAME
- vim /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
DAV svn
SVNParentPath /var/lib/svn/repository
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
Require valid-user
</Location>
vim /etc/apache2/dav_svn.authz
[PROJECT_NAME:/]
* =
ACCOUNT1 = r
ACCOUNT2 = rw
# 建帳號
- /usr/bin/htpasswd -c /etc/apache2/dav_svn.passwd ACCOUNT1
- /usr/bin/htpasswd /etc/apache2/dav_svn.passwd ACCOUNT2
# test & import
- cd /tmp/
- svn co http://DOMAIN_NAME/svn/PROJECT_NAME/
- cd PROJECT_NAME
- mkdir branches tags trunk
- svn import http://DOMAIN_NAME/svn/PROJECT_NAME/ -m 'inintial import'
- # subversion finish.
# trac
- apt-get install trac libapache2-mod-python
- mkdir -p /var/lib/trac/
- trac-admin /var/lib/trac/PROJECT_NAME initenv
My Project => PROJECT_NAME
/path/to/repos => /var/lib/svn/repository/PROJECT_NAME
vim /var/lib/trac/PROJECT_NAME/conf/trac.ini
default_charset = iso-8859-15 => default_charset = utf-8
# test: tracd --port 8000 /var/lib/trac/PROJECT_NAME
# trac-admin 新增帳號這些動作, 會記在 db/trac.db 裡面, 由此處可統一控管所有帳號權限, 和是否可以連進來等.
- trac-admin /var/lib/trac/PROJECT_NAME permission remove anonymous '*'
- # TRAC_ADMIN(需要全部大寫, 設此帳號為管理者, 此 TRAC_ADMIN 不是可代換變數 )
- trac-admin /var/lib/trac/PROJECT_NAME permission add ACCOUNT TRAC_ADMIN
vim /etc/apache2/sites-available/PROJECT_NAME.conf
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/lib/trac
ServerName VIRTUAL_HOST_NAME
ErrorLog /var/log/apache2/trac-error.log
CustomLog /var/log/apache2/trac-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"
# 跟 svn account 同一個檔即可.
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</LocationMatch>
</VirtualHost>
再 ln -s /etc/apache2/sites-available/PROJECT_NAME.conf /etc/apache2/sites-enabled/PROJECT_NAME.conf
# test => Virtual Host & Trac
- http://VIRTUAL_HOST_NAME/trac/PROJECT_NAME
賀~ 到此就建置完成囉~
再來的是, 如果還要再加上其它 trac 跟 svn 的時後該如何加上去, 只要下述步驟即可:
# build new PROJECT_NAME in svn
- svnadmin create /var/lib/svn/repository/PROJECT_NAME
- find /var/lib/svn/repository/PROJECT_NAME -type f -exec chmod 660 {} \;
- find /var/lib/svn/repository/PROJECT_NAME -type d -exec chmod 2770 {} \;
- chown -R root.www-data /var/lib/svn/repository/PROJECT_NAME
- vim /etc/apache2/dav_svn.authz # add project & account permission
[PROJECT_NAME:/]
* =
ACCOUNT1 = r
ACCOUNT2 = rw
# 建立帳號
- # htpasswd 在這次記得千萬不要 -c (會蓋掉之前的所有紀錄, 變成只有此新帳號的檔案 XD)
/usr/bin/htpasswd -c /etc/apache2/dav_svn.passwd ACCOUNT1- /usr/bin/htpasswd /etc/apache2/dav_svn.passwd ACCOUNT2
# test & initial import
- cd /tmp/
- svn co http://DOMAIN_NAME/svn/PROJECT_NAME/
- cd PROJECT_NAME
- mkdir branches tags trunk
- svn import http://DOMAIN_NAME/svn/PROJECT_NAME/ -m 'inintial import'
- # subversion finish.
# trac
- trac-admin /var/lib/trac/PROJECT_NAME initenv
My Project => PROJECT_NAME
/path/to/repos => /var/lib/svn/repository/PROJECT_NAME
- vim /var/lib/trac/PROJECT_NAME/conf/trac.ini
default_charset = iso-8859-15 => default_charset = utf-8
- chown www-data:www-data -R /var/lib/trac/PROJECT_NAME
- trac-admin /var/lib/trac/PROJECT_NAME permission remove anonymous '*'
- 注意: TRAC_ADMIN(需要全部大寫, 設此帳號為管理者, 此 TRAC_ADMIN 不是可代換變數)
- trac-admin /var/lib/trac/PROJECT_NAME permission add ACCOUNT TRAC_ADMIN
- vim /etc/apache2/sites-enabled/PROJECT_NAME.conf
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/lib/trac # 這個不重要
ServerName VIRTUAL_HOST_NAME
ErrorLog /var/log/apache2/trac-error.log
CustomLog /var/log/apache2/trac-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"
# 跟 svn account 同一個檔即可.
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</LocationMatch>
</VirtualHost>
# add trac new account
- /usr/bin/htpasswd /etc/apache2/dav_svn.passwd ACCOUNT
- trac-admin /var/lib/trac/PROJECT_NAME permission add ACCOUNT TRAC_ADMIN
# 完成, SVN & TRAC URL
- svn co http://VIRTUAL_HOST_NAME/svn/PROJECT_NAME
- trac http://VIRTUAL_HOST_NAME/trac/PROJECT_NAME/
要備份的話, 直接備份下面三個目錄即可:
- /etc/apache2/conf.d
- /var/lib/svn
- /var/lib/trac
總結快速開帳號流程:
- /usr/bin/htpasswd /etc/apache2/dav_svn.passwd ACCOUNT
- trac-admin /var/lib/trac/PROJECT_NAME permission add ACCOUNT TRAC_ADMIN
- vim /etc/apache2/dav_svn.authz # 把帳號加入