Subversion is an open source version control system. Using Subversion, you can record the history of source files and documents. It manages files and directories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to files and directories.
We will use Apache 2.0 as a central authentication checkpoint. mod_authz_svn.so and mod_dav_svn.so ships with Subversion and they are placed under $APACHE_HOME/modules during installation if installed with apache. To install the subversion package:
yum install expat-devel wget --passive http://subversion.tigris.org/downloads/subversion-1.6.15.tar.gz tar -xvzf subversion-1.6.15.tar.gz wget --passive http://subversion.tigris.org/downloads/subversion-deps-1.6.15.tar.gz tar -xvzf subversion-deps-1.6.15.tar.gz cd subversion-1.6.15 ./configure --with-apxs=/usr/local/etc/httpd/bin/apxs --with-apr=/usr/local/etc/httpd/bin/apr-1-config --with-apr-util=/usr/local/etc/httpd/bin/apu-1-config --prefix=/usr/local/etc/subversion make make install
Via a custom module, httpd makes Subversion repositories available to clients via the WebDAV/DeltaV protocol (Web-based Distributed Authoring and Versioning), which is an extension to HTTP 1.1. This protocol takes the HTTP protocol and adds writing (specifically, versioned writing) capabilities. The result is a standardized, robust system that is conveniently packaged as part of the Apache 2.0 software, is supported by numerous operating systems and third-party products, and doesn’t require network administrators to open up yet another custom port.
To network your repository over HTTP, you basically need four components, available in two packages. You’ll need Apache httpd 2.0, the mod_dav DAV module that comes with it, Subversion, and the mod_dav_svn filesystem provider module distributed with Subversion. Once you have all of those components, the process of networking your repository is as simple as:
- Installing the mod_dav_svn plugin to mod_dav, which uses Subversion’s libraries to access the repository
- Configuring your httpd.conf file to export (or expose) the repository
We need to tell Apache where we keep our Subversion repository. The purpose of the Location directive is to instruct Apache to do something special when handling requests that are directed at a given URL or one of its children. In the case of Subversion, you want Apache to simply hand off support for URLs that point at versioned resources to the DAV layer. You can instruct Apache to delegate the handling of all URLs whose path portions begin with /svn/ to a DAV provider whose repository is located at /absolute/path/to/repository. To browse all projects on this repository by going to the root url (http://www.serveraddress.com/svn) add the following to the httpd.conf (/usr/local/etc/httpd/conf):
DAV svn SVNParentPath /var/svn SVNListParentPath On AuthType Basic AuthName "Subversion Repository" AuthUserFile /usr/local/etc/subversion/passwd Require valid-user
Once you add the above lines, you must restart apache2 web server.
Next, we must create /usr/local/etc/subversion/passwd file. This file contains user authentication details.
sudo htpasswd -c /usr/local/etc/subversion/passwd user_name
Now we can create our svn root:
mkdir /var/svn cd /var/svn
Now, we need to set some access permissions on those directories. Change the group ownership of /var/svn to daemon (the Apache user). Daemon needs write access to the svn directory, so use chmod to add the permissions for the group:
sudo chown daemon:daemon /var/svn sudo chmod g+rws /var/svn
Subversion stores all versioned data in a central repository. To begin, create a new repository, set the umask so that group members have r/w access to newly created subdirectories:
umask 002 svnadmin create /var/svn/project1