source: server/other/svnserver.xml@ 5a3d9be7

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 6.0 6.1 6.2 6.2.0 6.2.0-rc1 6.2.0-rc2 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 5a3d9be7 was 5a3d9be7, checked in by Igor Živković <igor@…>, 19 years ago

Subversion server corrections.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@2973 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 9.8 KB
Line 
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
20a <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
35use <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
39consists 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
43configuration. Create the svn user and group with the following
44commands:</para>
45
46<screen><userinput><command>groupadd svn &amp;&amp;
47useradd -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
50group dedicated to each repository for ease of administration. Create
51the svntest group for the test repository and add the svn user to that
52group with the following commands:</para>
53
54<screen><userinput><command>groupadd svntest &amp;&amp;
55usermod -G svntest svn</command></userinput></screen>
56
57<para>Additionally you should set <command>umask 002</command> while working
58with a repository so that all new files will be writable by owner and group.
59This 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 &amp;&amp;
63mv /usr/bin/svnserve /usr/bin/svnserve.orig &amp;&amp;
64cat &gt;&gt; /usr/bin/svn &lt;&lt; "EOF"</command>
65#!/bin/sh
66umask 002
67/usr/bin/svn.orig "$@"
68<command>EOF
69cat &gt;&gt; /usr/bin/svnserve &lt;&lt; "EOF"</command>
70#!/bin/sh
71umask 002
72/usr/bin/svnserve.orig "$@"
73<command>EOF
74chmod 0755 /usr/bin/svn{,serve}</command></userinput></screen>
75
76<note><para>If you use <application>Apache</application> for working with
77the repository over <acronym>HTTP</acronym>, even for anonymous access, you
78should wrap <command>/usr/sbin/httpd</command> in a similar
79script.</para></note>
80
81</sect3>
82
83<sect3><title>2. Create a <application>Subversion</application>
84repository.</title>
85
86<para>With subversion-1.1.0 and greater, a new type of repository
87data-store is available, <acronym>FSFS</acronym>. There is a tradeoff
88for speed with the new backend, however, the repository can now be
89placed on a network mount, and any corruption does not require an
90admin to recover the repository. For more information and comparison
91between <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"/>.
93Optionally you can pass <parameter>bdb</parameter> in place of
94<parameter>fsfs</parameter> in the following command to create a
95BerkelyDB data-store.</para>
96
97<para>Create a new <application>Subversion</application> repository with
98the following commands:</para>
99
100<screen><userinput><command>install -d -m0755 /srv &amp;&amp;
101install -d -m0755 -o svn -g svn /srv/svn/repositories &amp;&amp;
102svnadmin 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
105something useful. You'll need to have a predefined directory layout
106setup exactly as you want your repository to look. For example, here
107is a sample BLFS layout setup with a root of <filename>svntest/</filename>.
108You'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
121to 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
128repository, 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 &amp;&amp;
131chmod -R g+w /srv/svn/repositories/svntest &amp;&amp;
132chmod g+s /srv/svn/repositories/svntest/db &amp;&amp;
133usermod -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
136mentioned earlier, this eases administration of multiple repositories
137when using <application>OpenSSH</application> for authentication. Going
138forward, you'll need to add your regular user, and any additional users
139that you wish to have write access to the repository, to the svn and
140svntest 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
144not immediately obvious, when using any external authentication method
145(such as <command>ssh</command>), the sticky bit is set so that all new files
146will be owned by the user, but group of svntest. Anyone in the svntest group
147can create files, but still give the entire group write access to those
148files. 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
151your 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
156memberships. '<command>su <replaceable>[username]</replaceable></command>'
157should 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
164server to use only <command>ssh</command> for write access to the repository
165and to provide anonymous access using <command>svnserve</command>. There are
166several other ways to provide access to the repository. These additional
167configurations 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
171the <filename>svnserve.conf</filename> file for the svntest repository
172using 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 &amp;&amp;
176cat &gt; /srv/svn/repositories/svntest/conf/svnserve.conf &lt;&lt; "EOF"</command>
177[general]
178anon-access = read
179auth-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
183that 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
191most common way is to start it as an <command>inetd</command> or
192<command>xinetd</command> process. Alternately, you can use a
193bootscript to start the service at startup.</para>
194
195<note><para>If you do not wish to provide anonymous access to your svn
196repositories or use <command>svnserve</command>'s built-in
197authentication, 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 &gt;&gt; /etc/inetd.conf &lt;&lt; "EOF"</command>
204svn 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
208lines to the <filename>/etc/xinetd.conf</filename> file:</para>
209
210<screen><userinput><command>cat &gt;&gt; /etc/xinetd.conf &lt;&lt; "EOF"</command>
211service 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
224startup, 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
Note: See TracBrowser for help on using the repository browser.