Setup svn » Historie » Version 2
Jeremias Keihsler, 11.11.2024 09:36
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 | <pre><code class="bash"> |
||
99 | mkdir /var/www/svn |
||
100 | cd /var/www/svn |
||
101 | |||
102 | svnadmin create testrepo |
||
103 | chown -R apache:apache testrepo |
||
104 | |||
105 | chcon -R -t httpd_sys_content_t /var/www/svn/testrepo |
||
106 | </code></pre> |
||
107 | Following enables commits over http |
||
108 | <pre><code class="bash"> |
||
109 | chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo |
||
110 | </code></pre> |
||
111 | |||
112 | h3. Configure SVN repository |
||
113 | |||
114 | To *disable anonymous access* and enable *access control* add following rows to @testrepo/conf/svnserve.conf@ |
||
115 | <pre> |
||
116 | ## Disable anonymous access ## |
||
117 | anon-access = none |
||
118 | |||
119 | ## Enable access control ## |
||
120 | authz-db = authz |
||
121 | </pre> |
||
122 | |||
123 | h3. Create trunk, branches and tags structure under testrepo |
||
124 | |||
125 | Create “template” directories with following command: |
||
126 | <pre><code class="bash"> |
||
127 | mkdir -p /tmp/svn-structure-template/{trunk,branches,tags} |
||
128 | </code></pre> |
||
129 | Then import template to project repository using @svn import@ command: |
||
130 | <pre><code class="bash"> |
||
131 | svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/ |
||
132 | </code></pre> |
||
133 | |||
134 | h3. Setup User/Repo based access control |
||
135 | |||
136 | Create “template” directories with following command: |
||
137 | <pre><code class="bash"> |
||
138 | vim /etc/svn-authz-users |
||
139 | </code></pre> |
||
140 | Then import template to project repository using @svn import@ command: |
||
141 | <pre> |
||
142 | # Allow full access to all repos |
||
143 | [/] |
||
144 | * = |
||
145 | master = rw |
||
146 | |||
147 | [homepage:/] |
||
148 | * = |
||
149 | master = rw |
||
150 | external_chk = r |
||
151 | |||
152 | # Lock MyRepo Branch_A |
||
153 | # Note that you only need the MyRepo: prefix if you have more than one repo |
||
154 | [janus:/z_Deploy] |
||
155 | * = r |
||
156 | master = rw |
||
157 | |||
158 | [janus:/11002] |
||
159 | * = r |
||
160 | master = rw |
||
161 | developer = rw |
||
162 | |||
163 | [ATX_Neuenstein:/] |
||
164 | * = |
||
165 | master = rw |
||
166 | client = r |
||
167 | |||
168 | # Lock all tags in all repos; only allow 'master' to create new tags. |
||
169 | [/tags] |
||
170 | * = r |
||
171 | master = rw |
||
172 | |||
173 | </pre> |
||
174 | |||
175 | h2. Start Apache and modify firewall rules |
||
176 | |||
177 | Start Apache: |
||
178 | |||
179 | <pre><code class="bash"> |
||
180 | systemctl start httpd.service |
||
181 | systemctl enable httpd.service |
||
182 | </code></pre> |
||
183 | |||
184 | Open the HTTP service port: |
||
185 | |||
186 | <pre><code class="bash"> |
||
187 | firewall-cmd --zone=public --permanent --add-service=http |
||
188 | firewall-cmd --reload |
||
189 | </code></pre> |
||
190 | |||
191 | h2. Usage |
||
192 | |||
193 | open in your browser |
||
194 | <pre><code class="bash"> |
||
195 | http://localhost/svn/testrepo/ |
||
196 | </code></pre> |
||
197 | |||
198 | h2. SSL secured web-server |
||
199 | |||
200 | see also http://wiki.centos.org/HowTos/Https |
||
201 | |||
202 | h2. Backup/Restore SVN repositories |
||
203 | |||
204 | [[dw_dr:SVN17| Backup/Restore SVN]] |