[root@xieping ~]# rpm -qa | grep subversion
[root@xieping ~]# yum remove subversion
[root@xieping ~]# yum install -y subversion
[root@xieping ~]# svnserve --version
[root@xieping ~]# mkdir -p /opt/svn/repo
[root@xieping ~]# svnadmin create /opt/svn/repo
[root@xieping ~]# cd /opt/svn/repo/conf
[root@xieping conf]# vim passwd
修改passwd为以下内容:
[users]
# harry = harryssecret
# sally = sallyssecret
hello=123
aaa = 123
www = 123
#用户名=密码
#以上语句都必须顶格写, 左侧不能留空格, 否则会出错.
[root@xieping conf]# vim authz
#目的是设置哪些用户可以访问哪些目录,向authz文件追加以下内容:
#设置[版本库:/路径]代表根目录下所有的资源
[groups]
admin = hello,www
[repos:/]
@admin = rw
aaa = r
#将用户添加到组,利用组来设置权限,也可以不需要租,直接在版本库下设置用户,例如
aaa = r ,意思是aaa用户对repos测试库下所有的目录有读权限,而hello和www有读写权限。
如果是自己用,就直接是读写吧。
[root@xieping conf]# vim svnserve.conf
[general]
#匿名访问的权限,可以是read,write,none,默认为read
anon-access=none
#使授权用户有写权限
auth-access=write
#密码数据库的路径
password-db=passwd
#访问控制文件
authz-db=authz
#认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字
realm=/opt/svn/repo
[root@xieping conf]#vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
[root@xieping conf]#service iptables restart
[root@xieping conf]#svnserve -d -r /opt/svn/repo
[root@xieping conf]#ps -ef|grep svn
root 12538 1 0 14:40 ? 00:00:00 svnserve -d -r /opt/svn/repo
[root@xieping conf]#netstat -ln |grep 3690
[root@xieping conf]#killall svnserve
[root@xieping conf]#svnserve -d -r /opt/svn/
#如果已经有svn在运行,可以换一个端口运行
#svnserve -d -r /opt/svn/ --listen-port 3391
#例如将当前目录导入版本库repo:
[root@xieping conf]#svn import . file:///opt/svn/repo -m "1.txt"
导出版本库数据
[root@xieping conf]#svn co file:///opt/svn/repo
TortoiseSVN(SVN客户端)
http://tortoisesvn.net/downloads.html
删除历史版本
[root@xieping conf]#find . -type d -name ".svn"|xargs rm -rf
整合SVN与apache
[root@xieping conf]# yum install -y httpd mod_dav_svn
[root@xieping conf]# vim /etc/httpd/conf/httpd.conf
#在文件最后面添加
<Location /svn>
DAV svn
SVNPath /opt/svn/repo
</Location>
[root@xieping conf]# /etc/init.d/httpd start
[root@xieping conf]# chkconfig httpd on
浏览器访问 http://192.168.0.143/svn/
浏览到目录为正确
创建通过网页访问版本库的密码访问,
修改http配置文件,添加如下行
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
<Location /svn>
DAV svn
SVNPath /opt/svn/repo
AuthType Basic
AuthName "wellcome"
AuthUserFile /opt/svn/apache_passwd
AuthzSVNAccessFile /opt/svn/apache_authz
Require valid-user
</Location>
[root@xieping conf]# htpasswd -c /opt/svn/apache_passwd www
#-c创建密码文件apache_passwd,只需首次创建用,其余不用-c
[root@xieping conf]# htpasswd /opt/svn/apache_passwd xieping
[root@xieping conf]# cat /opt/svn/apache_passwd