出自: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://zhaogongyu@192.168.255.69:/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
本文转自holy2009 51CTO博客,原文链接:http://blog.51cto.com/holy2010/443324