Installing Subversion on Fedora

My server uses Fedora so I can't go into more detail about installing on other systems. I found the install straight forward, but there were a few things I wanted to change along the way.

Firstly, we can use yum to do the install:

yum install svn mod_dav_svn

mod_dav_svn is used to hook Subversion into Apache - it means we can access our repositories using URLs, so as long as you've got internet access you can access your code.

This will add the file /etc/httpd/conf.d/subversion.conf which hooks into apache. However, I run multiple subdomains and a secure subdomain, and I'd rather have my checkouts going via my secure subdomain. So, I commented out almost the entire file (by adding '#' at the start of each line) - apart from the two lines that start 'LoadModule' - without these it won't work at all!

I then edited /etc/httpd/conf.d/ssl.conf instead, and within the <VirtualHost> definition I added:

<Location /svn>
   DAV svn
   SVNParentPath /subversion/public
 
   AuthzSVNAccessFile /subversion/conf/authz.policy
   SVNPathAuthz off
 
   # Require SSL connection for password protection.
   # SSLRequireSSL
 
   AuthType Basic
   AuthName "Subversion at dJomp"
   AuthUserFile /subversion/conf/.htpasswd
   Require valid-user
</Location>

Here I tell mod_dav_svn that my repositories will be at /subversion/public/ and the conf files are under /subversion/conf/. I've not created repositories or the configuration files yet, but that's fine - just don't restart apache until you do!

Next, let's create our first Subversion repository.

cd /subversion/public
svnadmin create reponame
chown -R apache:apache reponame

Note the user that we chown the directory to. Since we're accessing through URLs, apache will be doing the donkey work for us, so it needs access to everything.

OK, now we need to set up the configuration files. Let's first define some users and passwords. For the first user we must create the .htpasswd file:

htpasswd -c /subversion/conf/.htpasswd djomp

Then we just add a new user each time by dropping the -c flag:
htpasswd /subversion/conf/.htpasswd djomp

Now we have users, we can define permissions on repositories in /subversion/conf/authz.policy. The content looks something like:

[repo1:/]
djomp = rw
* = r
 
[repo2:/]
bob = rw

This will give the user 'djomp' read/write access, and any other user read-only, for the repository repo1; and only 'bob' has access to repo2. We can define blocks like this for all our repositories.

The final step is to get apache to read in the configuration files again so it'll start working:

service httpd reload

That's it - we now have subversion installed and working, with a working repository!