Projekt

Allgemein

Profil

Setup svn » Historie » Version 6

Jeremias Keihsler, 03.10.2017 18:25

1 1 Jeremias Keihsler
h1. Install SVN-Server
2
3
h2. Requirements
4
5 2 Jeremias Keihsler
To install svn you will need the following:
6 1 Jeremias Keihsler
* a installed and supported operating system (e.g. CentOS 7.x)
7
* root-access
8
* a fast internet connection
9
10
h2. Preliminary note
11
12
most of this is taken from 
13
* [[http://www.if-not-true-then-false.com/2010/install-svn-subversion-server-on-fedora-centos-red-hat-rhel/]]
14
* [[http://www.petefreitag.com/item/665.cfm]]
15
16
* setup rules-file [[http://www.startupcto.com/server-tech/subversion/locking-a-branch-in-svn]]
17
* @ssh+svn@ may be taken from [[http://www.startupcto.com/server-tech/subversion/setting-up-svn]]
18
This procedure is for a vanilla OS, if @Apache@ is already installed and configured you may have to rethink the configuration.
19
20
h2. Install
21
22
<pre><code class="bash">
23
yum install mod_dav_svn subversion
24
</code></pre>
25
26
h2. Configuration
27
28
h3. /etc/http/conf.d/subversion.conf
29
30
modify the preinstalled @etc/http/conf.d/subversion.conf@ analogue to
31
<pre>
32
LoadModule dav_svn_module     modules/mod_dav_svn.so
33
LoadModule authz_svn_module   modules/mod_authz_svn.so
34
 
35
<Location /svn>
36
   DAV svn
37
   SVNParentPath /var/www/svn
38
   AuthType Basic
39
   AuthName "Subversion repositories"
40
   AuthUserFile /etc/svn-auth-users
41
   AuthzSVNAccessFile  /etc/svn-authz-users
42
   Require valid-user
43
</Location>
44
</pre>
45
46 6 Jeremias Keihsler
if you placed the svn-server behind a proxy and you are experiencing '502 Bad Gateway' when copying then you may also rewrite the Destination inside the Header:
47
48
<pre>
49
LoadModule dav_svn_module     modules/mod_dav_svn.so
50
LoadModule authz_svn_module   modules/mod_authz_svn.so
51
52
# rename Destination to prevent 502 Bad Gateway Error when renaming files
53
RequestHeader edit Destination ^https http early
54
 
55
<Location /svn>
56
   DAV svn
57
   SVNParentPath /var/www/svn
58
   AuthType Basic
59
   AuthName "Subversion repositories"
60
   AuthUserFile /etc/svn-auth-users
61
   AuthzSVNAccessFile  /etc/svn-authz-users
62
   Require valid-user
63
</Location>
64
</pre>
65
66
67 1 Jeremias Keihsler
h3. Add SVN users
68
69 5 Jeremias Keihsler
* first-time usage (will clear any existing user!)
70 1 Jeremias Keihsler
<pre><code class="bash">
71
htpasswd -cm /etc/svn-auth-users testuser
72
</code></pre>
73
* follow up usage
74
<pre><code class="bash">
75
htpasswd -m /etc/svn-auth-users testuser
76
</code></pre>
77
Note: Use exactly same file and path name as used on @subversion.conf@ file. This example use @/etc/svn-auth-users@ file.
78
79
h3. Create SVN repository
80
81
<pre><code class="bash">
82
mkdir /var/www/svn
83
cd /var/www/svn
84
 
85
svnadmin create testrepo
86
chown -R apache:apache testrepo
87
 
88
chcon -R -t httpd_sys_content_t /var/www/svn/testrepo
89
</code></pre>
90
Following enables commits over http
91
<pre><code class="bash">
92
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo
93
</code></pre>
94
95
h3. Configure SVN repository
96
97
To *disable anonymous access* and enable *access control* add following rows to @testrepo/conf/svnserve.conf@
98
<pre>
99
## Disable anonymous access ##
100
anon-access = none
101
 
102
## Enable access control ##
103
authz-db = authz
104
</pre>
105
106
h3. Create trunk, branches and tags structure under testrepo
107
108
Create “template” directories with following command:
109
<pre><code class="bash">
110
mkdir -p /tmp/svn-structure-template/{trunk,branches,tags}
111
</code></pre>
112
Then import template to project repository using @svn import@ command:
113
<pre><code class="bash">
114
svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
115
</code></pre>
116
117
h3. Setup User/Repo based access control
118
119
Create “template” directories with following command:
120
<pre><code class="bash">
121
vim /etc/svn-authz-users
122
</code></pre>
123
Then import template to project repository using @svn import@ command:
124
<pre>
125
# Allow full access to all repos
126
[/]
127
* = 
128
master = rw
129
130
[homepage:/]
131
* =
132
master = rw
133
external_chk = r
134
135
# Lock MyRepo Branch_A
136
# Note that you only need the MyRepo: prefix if you have more than one repo
137
[janus:/z_Deploy]
138
* = r
139
master = rw
140
141
[janus:/11002]
142
* = r
143
master = rw
144
developer = rw
145
146
[ATX_Neuenstein:/]
147
* = 
148
master = rw
149
client = r
150
151
# Lock all tags in all repos; only allow 'master' to create new tags.
152
[/tags]
153
* = r
154
master = rw
155
156
</pre>
157
158
h2. Usage
159
160
open in your browser
161
<pre><code class="bash">
162
http://localhost/svn/testrepo/
163
</code></pre>
164
165
h2. SSL secured web-server
166
167
see also http://wiki.centos.org/HowTos/Https
168
169
h2. Backup/Restore SVN repositories
170
171 3 Jeremias Keihsler
[[dw_dr:SVN16| Backup/Restore SVN]]