安装服务包:
yum install -y httpd subversion mod_dav_svn
创建svn仓库
[root@localhost ~]# mkdir -p /data/svn/repos/ [root@localhost ~]# svnadmin create /data/svn/repos/
添加svn仓库的授权用户
[root@localhost ~]# cd /data/svn/repos/conf/ [root@localhost conf]# ls authz passwd svnserve.conf [root@localhost conf]# vim svnserve.conf ############################################### anon-access = none #禁止匿名用户 password-db = passwd #配置用户信息文件名 realm = /data/svn/repos #指定仓库路径 ############################################### #添加授权用户 [root@localhost conf]# vim passwd ############################################### [users] # harry = harryssecret # sally = sallyssecret user = 123.com zhangsan = 123456 ############################################### [root@localhost conf]# vim authz ############################################### [groups] dev = user,zhangsan [/] user = r @dev = rw ###############################################
此时启动svn服务后只能通过svn协议来访问
[root@localhost conf]# svnserve -d -r /data/svn/
HTTP访问配置
[root@localhost conf]# vim /etc/httpd/conf.d/svn.conf ################################################# <Location /repos> DAV svn SVNPath /data/svn/repos # Limit write permission to list of valid users. #<LimitExcept GET PROPFIND OPTIONS REPORT> # Require SSL connection for password protection. # SSLRequireSSL AuthType Basic AuthName "Authorization Realm" AuthUserFile /data/svn/repos/conf/passwd AuthzSVNAccessFile /data/svn/repos/conf/authz Satisfy all Require valid-user #</LimitExcept> </Location> #################################################
配置文件调整
将原用户信息文件备份 [root@localhost conf]# mv passwd passwd.bak 以后通过htpasswd来创建用户信息(-c是创建文件,以后只写-b添加新用户) htpasswd -cb passwd zhangsan 123456 htpasswd -b passwd lisi 1234
#新用户记得加入authz文件中
#就得修改SVN仓库所属用户及所属组
[root@localhost conf]# chown -R apache.apache /data/svn/repos/
重启svn和http服务
[root@localhost conf]# systemctl restart httpd.service