Moving Beyond SSH: Configuring Subversion

Published on Jul 11, 2009   //  Development
Off

Moving Beyond SSH

Last week we installed Subversion on our server. Today we’ll be going over how to configure Subversion so that we’ll be able to use it. We’ll begin by creating a Subversion repository, setting the correct permissions and then configuring Apache to allow us access to our repositories.

Before we begin going over that, I would recommend setting up a subdomain specifically to access your repositories. We will base our configurations on this fact (we will use svn.example.com, as it makes Subversion access easier to configure. You can setup a subdomain by logging into Webmin, going to your BIND configuraton, clicking the domain you want the subdomain on, clicking on Address, fill in svn in the Name field and your server’s IP address in the Address field. Click on Create then apply the configuration and restart BIND.

Creating a Subversion Repository

Creating a Subversion repository is a quick, one command process. Begin by logging into your server via SSH and changing your current directory to /home/svn/repos. Then run the following command to create your repository, replacing name with the desired name of your repository (no spaces or special characters):

svnadmin create name

Setting Permissions on the Repository

To allow Apache to have access to our repository, we’ll need to set special permissions on the repository. We can do this by running these two commands (again, replacing name with the name of your repository):

chmod -R g+w name
chgrp -R apache name

Configuration

Before we can actually access our Subversion repositories, we need to tell Apache to route requests for them appropriately. The way we’ll configure Apache is that each repository will need a separate configuration. This will allow us to have different access permissions and users for each repository. We’ll be adding this configuration to our virtual hosts configuration file. Start by opening that file in SSH (the file is /usr/local/apache2/conf/extra/httpd-vhosts.conf). Now, add the following configuration to the file. Replace name with the name of your repository and example.com with the domain you configured with a subdomain earlier.

[code language="plain"]<VirtualHost *:80>
ServerName svn.example.com
ServerAlias www.svn.example.com .svn.example.com
DocumentRoot "/home/svn/public_html"
<Location /name>
DAV svn
SVNPath /home/svn/repos/name
</Location>
</VirtualHost>[/code]

The first part of this sets up our subdomain as a virtual host. The Location part is the part where Apache finds out how to handle this type of request. For each of your repositories, you’ll need one of these Location blocks.

Currently our repository gives full access permissions to anonymous users. In our next article, we’ll be going over how to control the access permissions for your repositories.