出自:http://blog.sina.com.cn/s/blog_53b95aec0100i638.html
http://wiki.centos.org/HowTos/Subversion
http://www.akii.org/2010-04/centos-install-configure-subversion-and-submitted-to-automatic-release/
檢視linux詳細版本指令
lsb_release -a
工具版本
svn :svn, version 1.4.2
linux :CentOS release 5.4 (Final)
SVN形式
1.yum install mod_dav_svn subversion httpd
(vim /etc/httpd/conf/httpd.conf -- Edit what you need and save the file
service httpd start
chkconfig httpd on
)
2.
cd /etc/httpd/conf.d/
vim subversion.conf
<Location /repos>
DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>
在一個svn目錄下建立多個項目的方法
vim /etc/httpd/conf.d/subversion.conf
更改 SVNPath =》 SVNParentPath
SVNParentPath /var/www/svn/repos
這樣在cd /var/www/svn/repos/
svnadmin create testsvn1
在用戶端就可以通路
svn://192.168.255.71/testsvn1
3.
cd /var/www/
mkdir svn
cd svn
mkdir repos
cd repos
4.
cd /var/www/svn/repos/
svnadmin create testsvn來建立一個庫
chown root.root testsvn給予apache的權限
5.開啟svn
svnserve -d -r /var/www/svn/repos
6.配置
vim /var/www/svn/repos/testsvn/conf/svnserve.conf
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
當用show log 指令時候 會出現 'Item is not readable' 的問題解決辦法
在snvserve.conf設定 anon-access = none
7.設定svn使用者通路權限
7.1.單人登入
vim /var/www/svn/repos/testsvn/conf/passwd
gongyu=gongyu
vim /var/www/svn/repos/testsvn/conf/authz
[/]
* = rw
7.2.按組登入
當允許tester組進行删改操作時候 gongyu使用者是不能進行修改工作的
vim /var/www/svn/repos/testsvn/conf/passwd
gongyu=gongyu
test = test
test1 = test1
vim /var/www/svn/repos/testsvn/conf/authz
[groups]
master = gongyu
tester = test,test1
[/]
@tester = rw
7.3按組和按檔案夾目錄分開控制權限
tester組使用者可以讀寫src但不能讀寫doc
gongyu使用者可以讀寫doc但不能讀寫src
vim /var/www/svn/repos/testsvn/conf/passwd
gongyu=gongyu
test = test
test1 = test1
vim /var/www/svn/repos/testsvn/conf/authz
[groups]
master = gongyu
tester = test,test1
[/]
@tester = rw
[testsvn:/doc]
gongyu = rw
@tester = r
[testsvn:/src]
@tester = rw
8.關閉伺服器防火牆或者開啟端口
service iptables stop
開啟防火牆端口
service iptables restart
vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
用戶端運作
svn://192.168.255.71/testsvn
-------------------------------------------
svn+ssh形式
方法:ssh驗證 需要svn伺服器中建立真實linux使用者名,使svn伺服器允許此使用者通路
svn驗證 需要對目前使用者驗證是否可以通路svn項目權限
http://blog.csdn.net/wangjingfei/archive/2010/03/28/5424338.aspx
1.yum install mod_dav_svn subversion
2.cd /etc/httpd/conf.d/
vim subversion.conf
<Location /repos>
DAV svn
SVNParentPath /var/www/svn/repos
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>
3.
cd /var/www/
mkdir svn
cd svn
mkdir repos
cd repos
4.
useradd zhaogongyu 添加使用者
passwd zhaogongyu 添加密碼
groupadd svn 添加svn使用者組
usermod -a -G svn zhaogongyu 将使用者添加到svn使用者組
5.
cd /var/www/svn/repos/
svnadmin create testsvn來建立一個庫
chown -R root.svn /var/www/svn/repos/testsvn69
chmod -R g+rws | 775 /var/www/svn/repos/testsvn69
6.開啟svn
svnserve -d -r /var/www/svn/repos
7.配置
vim /var/www/svn/repos/testsvn69/conf/svnserve.conf
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
添權重限
vim /var/www/svn/repos/testsvn69/conf/authz
[groups]
svn = zhaogongyu
[/]
@svn = rw
#zhaogongyu = rw
* = rw
vim /var/www/svn/repos/testsvn69/conf/passwd
zhaogongyu=zhaogongyu
開啟防火牆端口
service iptables restart
vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
8. 用戶端通路位址
svn://192.168.255.69/testsvn69
9.增加ssh元件
yum install openssh-server
10.切換使用者生成密鑰
su zhaogongyu
cd /var/www/svn/repos/chinapaysvn/conf
ssh-keygen -b 1024 -t rsa -N zhaogongyu -f zhaogongyu
會在目前目錄中生成密鑰
zhaogongyu zhaogongyu.pub
11.導入密鑰
建立/home/zhaogongyu/.ssh 目錄
mkdir /home/zhaogongyu/.ssh
拷入公鑰檔案
cp /var/www/svn/repos/testsvn69/conf/zhaogongyu.pub /home/zhaogongyu/.ssh/authorized_keys
12.windows下運作
用pageant.exe, putty.exe, puttygen.exe
生成putty密鑰
打開puttygen.exe
選擇菜單:conversions->Import key
導入gongyu密鑰檔案
puTTygen:Enter Passphrase 輸入gongyu
此時可以看到該密鑰的一些資訊。點選Save private key,生成ppk檔案(假設儲存為gongyu.ppk檔案),即PuTTY使用的密鑰。
13.svn運作
在svn checkout 時候輸入
svn+ssh://[email protected]:/var/www/svn/repos/testsvn69
14.
添加新使用者
useradd test 添加使用者
passwd test 添加密碼
usermod -a -G svn zhaogongyu 将使用者添加到svn使用者組
設定test 使用者權限
vim /var/www/svn/repos/testsvn69/conf/authz
[groups]
svn = zhaogongyu
developer = test
[/]
@svn = rw
@developer = r
#gongyu = rw
* = rw
vim /var/www/svn/repos/testsvn69/conf/passwd
zhaogongyu = zhaogongyu
test = test
切換使用者生成密鑰
su test
cd /var/www/svn/repos/chinapaysvn/conf
ssh-keygen -b 1024 -t rsa -N testsvn -f testsvn
建立/home/test/.ssh 目錄
mkdir /home/test/.ssh
拷入公鑰檔案
cp /var/www/svn/repos/testsvn69/conf/test.pub /home/test/.ssh/authorized_keys