Federico Cargnelutti / Wiki

Resources:Subversion Install

From Federico Cargnelutti

Jump to: navigation, search

Prerequisites

For this article I'm assuming you have a working installation of Fedora Core 4, including the Apache web server. If you need any help getting to this point, this is a very extensive tutorial. In addition, I have also configured Samba, to enable remote Windows access to my code, but this is not a requirement for this tutorial.

Installation

In all honesty, this article is largely based on this tutorial. However, working through it myself, I found some things can be done better, some steps I did not have to do at all, and some steps simply did not work the way I expected. This article is my interpretation of the tutorial, which works for me.

As I said, installing SubVersion really is not a simple process. In fact it is, integrating it with Apache is what makes it hard, or not intuitive to say the least. I got it working using the following set of steps:

1. Install SubVersion

Run the following command in the terminal to start the graphical package manager:

 * system-config-packages
     

Next, scroll down to "Development Tools" and click on "Details". From the list, select "SubVersion", close the dialog and click on "Update". Fedora will ask you to insert the media that contains the packages.

2. Install mod_dav_svn

mod_dav_svn is the package that is needed for SubVersion to use the DAV feature of the Apache web server. Install it by running the following command:

 * yum install mod_dav_svn

Yum may ask you a few dependency questions. Always enter "Y" to confirm. When this process completes successfully, SubVersion is installed. You can test this by running "svnadmin" from the terminal.

3. Setting up directories

SubVersion needs a directory structure to hold repositories, users and permissions. We like to have these all in a convenient place for easy administration. Use the command line to create the following directories:

      mkdir /svn
      mkdir /svn/repos
      mkdir /svn/users
      mkdir /svn/permissions

Apache will need access to these directories, so issue the following command to recursively set the user id and group:

 * chown -R apache.apache /svn

Link Apache to SubVersion directories

It is now time to tell the Apache web server where it can find the SubVersion repositories. For this we need to include a location tag in the file "/etc/httpd/subversion.conf", which was automatically created when we installed the SubVersion packages. There are ways to link Apache to a repository, by repository location, or by parent path location. Since we would like the ability to have multiple repositories (without having to edit the config files for each new one), let's use the parent path scenario. Add the following lines to the "subversion.conf" file:

      <Location /svn/repos>
      DAV svn
      # any "/svn/repos/foo" URL will map to a repository /svn/repos/foo
      SVNParentPath /svn/repos
      </Location>

Save the config file and restart the Apache server:

 * service httpd reload

5. Creating our first repository

We now have the basic configuration work done. Create a first test repository, and allow Apache to access it:

 * svnadmin create /svn/repos/test
 * chown -R apache.apache /svn/repos/test

To test our basic installation, try to access "http://yourhostname/svn/repos/test/" in your browser. It should return you a revision number of the test repository.

6. Securing the repositories

While our current setup is working, anonymous version management is quite useless. Let's first prevent unauthorized users from accessing the online repositories. For this we first need to create a HTTP user:

 * htpasswd -cb /svn/users/passwords username password

Replace "username" and "password" with your desired username and password. I personally matched this with the account I use for Samba access, but you are free to choose. Next, we need to tell Apache where our HTTP users file is. Add the following lines between the location tags of the "subversion.conf" file we edited earlier:

      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /svn/users/passwords
      Require valid-user

Save the config file and restart the Apache server:

 * service httpd reload

To test our secured installation, try to access "http://yourhostname/svn/repos/test/" in your browser. It should now require you to log in. Use the username and password that you used when we created the HTTP user.

7. Repository authorizations

The last step is to define who is allowed to do what in the repositories. For this I'm following a very simple scenario, where a single user is allowed to read and write repositories. First, create a new file " /svn/permissions/svnauthz.conf", and insert the following lines:

     [/] fchristant = rw

Save the file. Our last step is to tell Apache where to find the authorizations file. Add the following line between the location tags of the "subversion.conf" file we edited earlier: AuthzSVNAccessFile /svn/permissions/svnauthz.conf

Save the config file and restart the Apache server:

 * service httpd reload
      

8. Roundup

As a final check, here is the complete "subversion.conf" file:

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

      <Location /svn/repos>
      DAV svn
      # any "/svn/foo" URL will map to a repository /svn/repos/foo
      SVNParentPath /svn/repos
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /svn/users/passwords
      Require valid-user
      AuthzSVNAccessFile /svn/permissions/svnauthz.conf
      </Location>
Personal tools