1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
5 | %general-entities;
|
---|
6 |
|
---|
7 | ]>
|
---|
8 |
|
---|
9 | <sect1 id="svnserver" xreflabel="Running a Subversion Server">
|
---|
10 | <sect1info>
|
---|
11 | <othername>$LastChangedBy$</othername>
|
---|
12 | <date>$Date$</date>
|
---|
13 | </sect1info>
|
---|
14 | <?dbhtml filename="svnserver.html"?>
|
---|
15 | <title>Running a Subversion Server</title>
|
---|
16 |
|
---|
17 | <sect2>
|
---|
18 | <title>Running a Subversion Server</title>
|
---|
19 | <para>This section will describe how to set up, administer and secure
|
---|
20 | a <application>Subversion</application> server.</para>
|
---|
21 |
|
---|
22 | <sect3><title><application>Subversion server</application> dependencies</title>
|
---|
23 | <sect4><title>Required</title>
|
---|
24 | <para><xref linkend="subversion"/> and <xref linkend="openssh"/></para>
|
---|
25 | </sect4>
|
---|
26 | </sect3>
|
---|
27 |
|
---|
28 | </sect2>
|
---|
29 |
|
---|
30 | <sect2>
|
---|
31 | <title>Setting up a <application>Subversion</application> server.</title>
|
---|
32 |
|
---|
33 | <para>The following instructions will install a
|
---|
34 | <application>Subversion</application> server, which will be set up to
|
---|
35 | use <application>OpenSSH</application> as the secure remote access method, with
|
---|
36 | <command>svnserve</command> available for anonymous access.</para>
|
---|
37 |
|
---|
38 | <para>Configuration of the <application>Subversion</application> server
|
---|
39 | consists of the following steps:</para>
|
---|
40 |
|
---|
41 | <sect3><title>1. Setup users, groups, and permissions</title>
|
---|
42 | <para>You'll need to be user root for the initial portion of
|
---|
43 | configuration. Create the svn user and group with the following
|
---|
44 | commands:</para>
|
---|
45 |
|
---|
46 | <screen><userinput><command>groupadd svn &&
|
---|
47 | useradd -c "SVN Owner" -d /home/svn -m -g svn -s /bin/false svn</command></userinput></screen>
|
---|
48 |
|
---|
49 | <para>If you plan to have multiple repositories, you should have a
|
---|
50 | group dedicated to each repository for ease of administration. Create
|
---|
51 | the svntest group for the test repository and add the svn user to that
|
---|
52 | group with the following commands:</para>
|
---|
53 |
|
---|
54 | <screen><userinput><command>groupadd svntest &&
|
---|
55 | usermod -G svntest svn</command></userinput></screen>
|
---|
56 |
|
---|
57 | <para>Additionally you should set <command>umask 002</command> while working
|
---|
58 | with a repository so that all new files will be writable by owner and group.
|
---|
59 | This is made mandatory by creating a wrapper script for
|
---|
60 | <command>svn</command> and <command>svnserve</command>:</para>
|
---|
61 |
|
---|
62 | <screen><userinput><command>mv /usr/bin/svn /usr/bin/svn.orig &&
|
---|
63 | mv /usr/bin/svnserve /usr/bin/svnserve.orig &&
|
---|
64 | cat >> /usr/bin/svn << "EOF"</command>
|
---|
65 | #!/bin/sh
|
---|
66 | umask 002
|
---|
67 | /usr/bin/svn.orig "$@"
|
---|
68 | <command>EOF
|
---|
69 | cat >> /usr/bin/svnserve << "EOF"</command>
|
---|
70 | #!/bin/sh
|
---|
71 | umask 002
|
---|
72 | /usr/bin/svnserve.orig "$@"
|
---|
73 | <command>EOF
|
---|
74 | chmod 0755 /usr/bin/svn{,serve}</command></userinput></screen>
|
---|
75 |
|
---|
76 | <note><para>If you use <application>Apache</application> for working with
|
---|
77 | the repository over <acronym>HTTP</acronym>, even for anonymous access, you
|
---|
78 | should wrap <command>/usr/sbin/httpd</command> in a similar
|
---|
79 | script.</para></note>
|
---|
80 |
|
---|
81 | </sect3>
|
---|
82 |
|
---|
83 | <sect3><title>2. Create a <application>Subversion</application>
|
---|
84 | repository.</title>
|
---|
85 |
|
---|
86 | <para>With subversion-1.1.0 and greater, a new type of repository
|
---|
87 | data-store is available, <acronym>FSFS</acronym>. There is a tradeoff
|
---|
88 | for speed with the new backend, however, the repository can now be
|
---|
89 | placed on a network mount, and any corruption does not require an
|
---|
90 | admin to recover the repository. For more information and comparison
|
---|
91 | between <acronym>FSFS</acronym> and <acronym>BDB</acronym>, plese see
|
---|
92 | <ulink url="http://svnbook.red-bean.com/svnbook-1.1/ch05.html#svn-ch-5-sect-1.2.A"/>.
|
---|
93 | Optionally you can pass <parameter>bdb</parameter> in place of
|
---|
94 | <parameter>fsfs</parameter> in the following command to create a
|
---|
95 | BerkelyDB data-store.</para>
|
---|
96 |
|
---|
97 | <para>Create a new <application>Subversion</application> repository with
|
---|
98 | the following commands:</para>
|
---|
99 |
|
---|
100 | <screen><userinput><command>install -d -m0755 /srv &&
|
---|
101 | install -d -m0755 -o svn -g svn /srv/svn/repositories &&
|
---|
102 | svnadmin create --fs-type fsfs /srv/svn/repositories/svntest</command></userinput></screen>
|
---|
103 |
|
---|
104 | <para>Now that the repository is created, we need to populate it with
|
---|
105 | something useful. You'll need to have a predefined directory layout
|
---|
106 | setup exactly as you want your repository to look. For example, here
|
---|
107 | is a sample BLFS layout setup with a root of <filename>svntest/</filename>.
|
---|
108 | You'll need to setup a directory tree similar to the following:</para>
|
---|
109 |
|
---|
110 | <screen> svntest/ # The name of the repository
|
---|
111 | trunk/ # Contains the existing source tree
|
---|
112 | BOOK/
|
---|
113 | bootscripts/
|
---|
114 | edguide/
|
---|
115 | patches/
|
---|
116 | scripts/
|
---|
117 | branches/ # Needed for additional branches
|
---|
118 | tags/ # Needed for tagging release points</screen>
|
---|
119 |
|
---|
120 | <para>Once you've created your directory layout as shown above, you are ready
|
---|
121 | to do the initial import:</para>
|
---|
122 |
|
---|
123 | <screen><userinput><command>svn import -m "Initial import." \
|
---|
124 | <replaceable>[/path/to/source/tree]</replaceable> \
|
---|
125 | file:///srv/svn/repositories/svntest</command></userinput></screen>
|
---|
126 |
|
---|
127 | <para>Now go ahead and change owner and group information on the
|
---|
128 | repository, and add your normal user to the svn and svntest groups:</para>
|
---|
129 |
|
---|
130 | <screen><userinput><command>chown -R svn:svntest /srv/svn/repositories/svntest &&
|
---|
131 | chmod -R g+w /srv/svn/repositories/svntest &&
|
---|
132 | chmod g+s /srv/svn/repositories/svntest/db &&
|
---|
133 | usermod -G svn,svntest,<replaceable>[insert existing groups]</replaceable> <replaceable>[username]</replaceable></command></userinput></screen>
|
---|
134 |
|
---|
135 | <para>svntest is the group assigned to the svntest repository. As
|
---|
136 | mentioned earlier, this eases administration of multiple repositories
|
---|
137 | when using <application>OpenSSH</application> for authentication. Going
|
---|
138 | forward, you'll need to add your regular user, and any additional users
|
---|
139 | that you wish to have write access to the repository, to the svn and
|
---|
140 | svntest groups.</para>
|
---|
141 |
|
---|
142 | <para>In addition, you'll notice that the new repository's
|
---|
143 | <filename>db</filename> directory is set-groupID. If the reasoning is
|
---|
144 | not immediately obvious, when using any external authentication method
|
---|
145 | (such as <command>ssh</command>), the sticky bit is set so that all new files
|
---|
146 | will be owned by the user, but group of svntest. Anyone in the svntest group
|
---|
147 | can create files, but still give the entire group write access to those
|
---|
148 | files. This avoids locking out other users from the repository.</para>
|
---|
149 |
|
---|
150 | <para>Now, go ahead and return to your normal user account, and take a look at
|
---|
151 | your new repository using <command>svnlook</command>:</para>
|
---|
152 |
|
---|
153 | <screen><userinput><command>svnlook tree /srv/svn/repositories/svntest/</command></userinput></screen>
|
---|
154 |
|
---|
155 | <note><para>You may need to log out and back in again to refresh your group
|
---|
156 | memberships. '<command>su <replaceable>[username]</replaceable></command>'
|
---|
157 | should work around this as well.</para></note>
|
---|
158 |
|
---|
159 | </sect3>
|
---|
160 |
|
---|
161 | <sect3><title>3. Configure the server</title>
|
---|
162 |
|
---|
163 | <para>As mentioned previously, these instructions will configure the
|
---|
164 | server to use only <command>ssh</command> for write access to the repository
|
---|
165 | and to provide anonymous access using <command>svnserve</command>. There are
|
---|
166 | several other ways to provide access to the repository. These additional
|
---|
167 | configurations are best explained at
|
---|
168 | <ulink url="http://svnbook.red-bean.com/"/>.</para>
|
---|
169 |
|
---|
170 | <para>Access configuration needs to be done for each repository. Create
|
---|
171 | the <filename>svnserve.conf</filename> file for the svntest repository
|
---|
172 | using the following commands:</para>
|
---|
173 |
|
---|
174 | <screen><userinput><command>cp /srv/svn/repositories/svntest/conf/svnserve.conf \
|
---|
175 | /srv/svn/repositories/svntest/conf/svnserve.conf.default &&
|
---|
176 | cat > /srv/svn/repositories/svntest/conf/svnserve.conf << "EOF"</command>
|
---|
177 | [general]
|
---|
178 | anon-access = read
|
---|
179 | auth-access = write
|
---|
180 | <command>EOF</command></userinput></screen>
|
---|
181 |
|
---|
182 | <para>There is not a lot to the configuration file at all. You'll notice
|
---|
183 | that only the general section is required. Take a look at the
|
---|
184 | <filename>svnserve.conf.default</filename> file for information on using
|
---|
185 | <command>svnserve</command>'s built-in authentication method.</para>
|
---|
186 |
|
---|
187 | </sect3>
|
---|
188 |
|
---|
189 | <sect3><title>4. Starting the server</title>
|
---|
190 | <para>There are a couple of ways to start <command>svnserve</command>. The
|
---|
191 | most common way is to start it as an <command>inetd</command> or
|
---|
192 | <command>xinetd</command> process. Alternately, you can use a
|
---|
193 | bootscript to start the service at startup.</para>
|
---|
194 |
|
---|
195 | <note><para>If you do not wish to provide anonymous access to your svn
|
---|
196 | repositories or use <command>svnserve</command>'s built-in
|
---|
197 | authentication, you do not need to run
|
---|
198 | <command>svnserve</command>.</para></note>
|
---|
199 |
|
---|
200 | <para>If you use <command>inetd</command>, add a line to
|
---|
201 | <filename>/etc/inetd.conf</filename> using the following commands:</para>
|
---|
202 |
|
---|
203 | <screen><userinput><command>cat >> /etc/inetd.conf << "EOF"</command>
|
---|
204 | svn stream tcp nowait svn /usr/bin/svnserve svnserve -i
|
---|
205 | <command>EOF</command></userinput></screen>
|
---|
206 |
|
---|
207 | <para>If you use <command>xinetd</command>, add the following
|
---|
208 | lines to the <filename>/etc/xinetd.conf</filename> file:</para>
|
---|
209 |
|
---|
210 | <screen><userinput><command>cat >> /etc/xinetd.conf << "EOF"</command>
|
---|
211 | service svn
|
---|
212 | {
|
---|
213 | port = 3690
|
---|
214 | socket_type = stream
|
---|
215 | protocol = tcp
|
---|
216 | wait = no
|
---|
217 | user = svn
|
---|
218 | server = /usr/bin/svnserve
|
---|
219 | server_args = -i -r /srv/svn/repositories
|
---|
220 | }
|
---|
221 | <command>EOF</command></userinput></screen>
|
---|
222 |
|
---|
223 | <para>Finally, if you wish to simply start the sever at
|
---|
224 | startup, install the svn bootscript included in the
|
---|
225 | <xref linkend="intro-important-bootscripts"/> package.</para>
|
---|
226 |
|
---|
227 | <screen><userinput><command>make install-svn</command></userinput></screen>
|
---|
228 |
|
---|
229 | </sect3>
|
---|
230 |
|
---|
231 | </sect2>
|
---|
232 |
|
---|
233 | </sect1>
|
---|
234 |
|
---|