Subversion for SysAdmins PDF Print E-mail
Written by David Torre   

ViewVC Configuration

Fortunately, the ViewVC configuration is fairly straight forward. Simply open up the viewvc.conf file (locate at /usr/local/viewvc-x.y.z/viewvc.conf by default), then modify the root_parents, the default_root, and finally the address parameters as follows:

root_parents = /var/www/svnroot : svn
# this is the name of the default root
# (ignored when root_as_url_component is turned on)
default_root = 
address = 
 This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
 

Don't worry about the svnroot directory yet, as we will be creating it shortly. The last thing we need to do here is tell ViewVC where to look when attempting to authenticate web users. Create a viewvc.conf Apache include file (perhaps at /etc/httpd/conf.d/viewvc.conf) and append the following to the the file:

 

ScriptAlias /viewvc /usr/local/viewvc-1.0.4/bin/cgi/viewvc.cgi
<Location />
AuthName "SVN Repository Authentication"
AuthType Basic
AuthUserFile /var/www/svnroot/svn-accounts
Require valid-user
</Location>

ViewVC should now be installed, configured, and ready to authenticate web users.

Apache Configuration

Since Apache will be serving up our SVN repositories via WebDAV, obviously WebDAV itself must be enabled. Although WebDAV is enabled by default on many Apache installations, we'll double-check by opening the main httpd.conf file (locate at /etc/httpd/conf/httpd.conf on Red Hat systems), and locating the “LoadModule” section. Once you've located this section, ensure you have the following line set:

LoadModule dav_module modules/mod_dav.so

If you installed mod_dav_svn via yum/rpm, you'll have an Apache include file located at: /etc/httpd/conf.d/subversion.conf. Go ahead and open this file, and ensure you have the following lines set:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

We'll now go ahead and create the root-level directory structure for our SVN repository, starting at /var/www/svnroot. All Subversion repositories, as well as security database files, will live at this location. (Note that lines beginning with # are comments)

#Create SVN root
[root@server viewvc-1.0.4]# mkdir /var/www/svnroot
#Create username/password database
[root@server viewvc-1.0.4]# touch /var/www/svnroot/svn-accounts
#Create permissions access file
[root@server viewvc-1.0.4]# touch /var/www/svnroot/svn-acl
[root@server viewvc-1.0.4]# chown -R apache.apache /var/www/svnroot/*

We now have a working root Subversion location, waiting for new projects!

Creating a New Repository

Creating a new repository is quite simple. Navigate to your SVN root directory (/var/www/svnroot) and invoke svnadmin create command, using your project name as a final argument. For example, if we wanted to create a repository named “oracle-ERP,” we'd issue the following command:

[root@server /]# cd /var/www/svnroot/
[root@server svnroot]# svnadmin create oracle-ERP

We now need to make sure the newly created “oracle-ERP” repository is writable by the web server user. For Red Hat systems, this is typically user 'apache.' To set the user and group ownership to Apache (or whoever your web server currently runs as), type the following as root:

[root@server svnroot]# chown -R apache.apache oracle-ERP/

Now that we've added our new repository, we need to tell mod_dav_svn that it exists. This is done by opening your subversion.conf Apache include file (located by default at: /etc/httpd/conf.d/subversion.conf) and appending the following to the end of the file:

<Location>
DAV svn
SVNPath /var/www/svnroot/oracle-ERP
AuthType Basic
AuthName "oracle-ERP"
AuthUserFile /var/www/svnroot/svn-accounts
Require valid-user
AuthzSVNAccessFile /var/www/svnroot/svn-acl
</Location>

Finally, let's restart Apache for our changes to take effect:

[root@server conf.d]# service httpd restart
Removing Repositories

The removal of a given repository is achieved simply through removing the directory structure located at the SVN root location, as well as any configuration directives in your subversion.conf include file. Specifically:

  1. Remove repository entry from /etc/httpd/conf.d/subversion.conf
  2. Delete the repository directory (and all sub-directories) from /var/www/svnroot

Adding Users and Groups

Since you'll most likely need your Subversion repositories to be password-protected, we'll walk through the creation of two users, and one group. Go ahead and open the file /var/www/svnroot/svn-acl, and add your organization's users and groups:

 

#
# specify groups here
#
[groups]
team-it = dave, jen
#
# Group "team-it" and a contractor named "mike" have read/write access to the
# squid-config repository. All others have read-only access
#
[squid-config:/]
@team-it = rw
mike = rw
* = r
#
# Group "team-it" has read-write access to the oracle-ERP repository.
# All others have no access
#
[oracle-ERP:/]
@team-it = rw

Now that we've established permissions on a couple SVN repositories, let's create passwords for the three users we referenced in svn-acl. This is done by invoking htpasswd to build our user database file, located at: /var/www/svnroot/svn-accounts:

[root@server svnroot]# htpasswd -m /var/www/svnroot/svn-accounts dave
New password: daves-password
Re-type new password: daves-password
Adding password for user dave
[root@server svnroot]# htpasswd -m /var/www/svnroot/svn-accounts jen
New password: jens-password
Re-type new password: jens-password
Adding password for user jen
[root@server svnroot]# htpasswd -m /var/www/svnroot/svn-accounts mike
New password: mikes-password
Re-type new password: mikes-password
Adding password for user mike
[root@server svnroot]#

Removing Users and Groups

Removing users and/or groups is done via editing the /var/www/svnroot/svn-accounts and /var/www/svnroot/svn-acl files using your favorite text editor. At this point, you have a working Subversion repository which you may use either via your favorite Subversion client{link}, or via the ViewVC interface, located at http://your-server.com/viewvc.

 



 
Copyright © 2006-2008 Atomic Fission