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