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