How to install and configure Subversion for use in professional development environments. This subversion will run as a module in Apache2 and will use it's own database of users. Installation and configuration of Subversion clients on Windows are also discussed.
Set the USE flags properly and emerge subversion. The output below shows the USE flags on the example server and some of the dependencies. Swig is the Simplified Wrapper and Interface Generator and neon is a DAV client.
root@carbon # emerge -pv subversion These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild N ] dev-lang/swig-1.3.21 -X -guile -java +perl +php -python -ruby -tcltk 1,975 kB [ebuild N ] app-shells/bash-completion-config-0.8-r2 106 kB [ebuild N ] net-misc/neon-0.24.7 -expat +ssl +zlib 589 kB [ebuild N ] dev-util/subversion-1.2.3 +apache2 +bash-completion -berkdb -emacs -java +nls -nowebdav +perl -python +zlib 7,068 kB
To run Subversion server one must first create the repository then configure the server type. Subversion can run with its own daemon (svnserve) with or without xinetd, via ssh or over http in Apache2. The example server is setup to use Apache2 and pointers are provided for use with https.
To create the repository use the
svnadmin command or use the built in ebuild piece.
The ebuild will create the repository as
/var/svn and set the owner properly.
root@carbon # ebuild /var/db/pkg/dev-util/subversion-1.2.3/subversion-1.2.3.ebuild config
To get Apache2 to host the Subversion stuffs it must be told to load the proper modules.
Update the Apache2 start command to enable DAV and SVN.
Ensure that the auth_module is loaded in apache2.conf, the SVN module needs it.
Specific configuration parameters are located in
root@carbon # grep APACHE2_OPTS /etc/conf.d/apache2 APACHE2_OPTS="-D DAV -D SVN" root@carbon # grep auth_module /etc/apache2/conf/apache2.conf LoadModule auth_module modules/mod_auth.so
Create the user database for access to the repository. It seems possible to plug this into a different auth database by editing apache2 and 47_mod_dav_svn.conf accordingly. The example server simply uses an htpasswd file in the default location which is set in 47_mod_dav_svn.conf
# First User root@carbon # htpasswd2 -b -c -m /var/svn/conf/svnusers user1 pass1 # Subsequent Users root@carbon # htpasswd2 -b -m /var/svn/conf/svnusers userN passN
The the repository is now available on the server at path
This location name is set in 47_mod_dav_svn.conf and can be altered, specifically a dedicated source server could be placed at the root by setting
Now is also a good time to configure Apache to block access to the Subversion working-copy directories.
If for example you were to
svn export to a webroot we don't want outsiders viewing our code.
We generally place this near the top of the Apache configuration to ensure it applies server-wide
<DirectoryMatch .*\.svn/.*> Deny From All </DirectoryMatch>
Subversion over Apache DAV can also take advantage of the AuthzSVNAccessFile configuration which points to a ACL definition file. The file is similar to the common .ini format.
Configure Apache as follows
SVNPath /var/svn/repos AuthUserFile /var/svn/conf/htpasswd AuthzSVNAccessFile /var/svn/conf/svnaccess
Here is an example ini file
[groups] dev = firstname.lastname@example.org adm = email@example.com [/] @dev = r @adm = rw [/one/project] * = @dev = rw @adm = r [/other/trunk] * = r @dev = r @adm = rw
There are many Subversion clients available for many systems. The Subversion project directly provides a CLI that will run on Windows, TortiseSVN is a Windows shell extension that looks pretty and has lots of features. Get it from their respective home pages (link below) and go crazy.