1、安装

1
2
3
4
5
6
yum -y install subversion httpd mod_dav_svn;
mkdir -p /data/svn/repo1;
svnadmin create /data/svn/repo1;
chown -R apache.apache /data/svn/repo1;
touch /data/svn/repo1/passwd;
#touch /data/svn/repo1/authz;
1
2
3
svn --version
svn, version 1.7.14 (r1542130)
   compiled Apr 11 2018, 02:40:28

2、配置httpd

1
2
# 默认配置文件,默认端口修改
/etc/httpd/conf/httpd.conf
1
vi /etc/httpd/conf.d/subversion.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
    DAV svn
    SVNPath /data/svn/repo1/
    AuthType Basic
    AuthName "Authorization Realm"
    AuthUserFile /data/svn/repo1/passwd
    AuthzSVNAccessFile /data/svn/repo1/conf/authz
    Require valid-user
</Location>
1
2
systemctl enable httpd
systemctl start httpd

3、启动

1
svnserve -d -r /data/svn/repo1
1
2
# 配置文件在
vi /data/svn/repo1/conf/svnserve.conf

4、创建用户

1
vi /data/svn/repo1/authz
1
2
3
4
5
[aliases]
[groups]
admin=admin
[/]
@admin=rw
1
2
htpasswd -n admin
htpasswd -b /data/svn/repo1/passwd  test 123456

5、异常

1
[Tue Jan 08 12:58:38.222816 2019] [authn_file:error] [pid 4975] (13)Permission denied: [client 127.0.0.1:37458] AH01620: Could not open password file: /data/svn/repo1/passwd
1
2
3
chown -R apache:apache /data/svn/repo1/passwd
chmod 0666 /data/svn/repo1/passwd
chcon -R -h -t httpd_sys_content_t /data/svn/repo1

6、nginx配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
location /svn {
	proxy_redirect off;
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	client_max_body_size 10m;
	client_body_buffer_size 128k;
	proxy_connect_timeout 65;
	proxy_send_timeout 65;
	proxy_read_timeout 65;
	proxy_buffer_size 4k;
	proxy_buffers 4 32k;
	proxy_busy_buffers_size 64k;
	proxy_pass http://127.0.0.1:8080/svn;
}

7、注意

1
2
3
#两个密码文件格式不一样
/data/svn/repo1/passwd #httpd Auth使用,使用htpasswd加密产生
/data/svn/repo1/conf/passwd #svnserve使用,密码为明文