SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS、CVS,它采用了分支管理系统,它的设计目标就是取代CVS。互联网上很多版本控制服务已从CVS迁移到Subversion。说得简单一点SVN就是用于多个人共同开发同一个项目,共用资源的目的
实验环境
centos6.5(x64)
软件安装
rpm -qa | grep subversion
yum install -y subversion*
svn --version
svn, version 1.6.11 (r934486) compiled Aug 17 2015, 08:37:43
mkdir -p /var/svn/test
svnadmin create /var/svn/test
cd /var/svn/test/
ls
conf db format hooks locks README.txt 建立文件库以后默认生成文件
vim /var/svn/test/conf/authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe 找到
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = admin,test1,test2 admin,test1,test2 为svn用户名
# [/foo/bar] 找到
# harry = rw
# &joe = r
# * =
# [/foo/bar]
# harry = rw
# &joe = r
# * =
[/]
@admin = rw
* = 添加这三行配置
vim /var/svn/test/conf/passwd
[users]
# harry = harryssecret 找到
# sally = sallyssecret
[users]
# harry = harryssecret
# sally = sallyssecret
admin = 123456
test1 = test1
test2 = test2 test1为用户名 test1为密码(添加三行用户名 密码)
vim /var/svn/test/conf/svnserve.conf
# anon-access = read 找到
# auth-access = write
# anon-access = read
# auth-access = write
anon-access = none
auth-access = write 改为
# password-db = passwd 找到
password-db = passwd 改为
# authz-db = authz 找到
authz-db = authz 改为
#realm = My First Repository 找到
realm = demo's svndata 改为 修改这几行必须顶到头,要么启动服务会报错
svnserve -d -r /var/svn --listen-host 192.168.1.160 启动服务
killall svnserve 停止服务
chkconfig --level 35 svnserve on
netstat -tuplna | grep svnserve
tcp 0 0 192.168.1.160:3690 0.0.0.0:* LISTEN 23370/svnserve
到此为止 svn服务端安装完毕
客户端软件名字为:TortoiseSVN
用户名为 passwd 文件用户名 密码
touch /etc/rc.d/init.d/svnd
chmod +x /etc/rc.d/init.d/svnd
vim /etc/rc.d/init.d/svnd
#!/bin/bash
case "$1" in
start)
svnserve -d -r /var/svn svn目录自行配置
svnport=`netstat -natp | grep svnserve | awk -F: '{print $4}' | awk 'NR==1'`
if [ $svnport -eq 3690 ]
then
echo "SVN Server Already Runnning. Port:3690"
else
echo "SVN Server Does Not Start"
fi
;;
reload)
svnport=`netstat -natp | grep svnserve | awk -F: '{print $4}' | awk 'NR==1'`
if [ $svnport -eq 3690 ]
then
killall svnserve && svnserve -d -r /svndata
echo "Reload OK"
else
echo "SVN Server Is Not Running"
fi
;;
stop)
killall svnserve
echo "SVN Server Has Been Stopped"
;;
status)
svnport=`netstat -natp | grep svnserve | awk -F: '{print $4}' | awk 'NR==1'`
pid=`ps aux | grep svnserve | grep -v "grep" | awk '{print $2}'`
if [ $svnport -eq 3690 ]
then
echo "SVN Server (pid:$pid) 正在运行..."
else
echo "SVN Server 停止运行..."
fi
;;
*)
echo "$0: Usage: $0 {start|status|stop|reload}"
exit 1
;;
esac
/etc/rc.d/init.d/svnd restart
本文转自 mailfile 51CTO博客,原文链接:http://blog.51cto.com/mailfile/1762515,如需转载请自行联系原作者