Setting up an SVN server on FreeBSD.


I currently run a freebsd server in my home.  Recently, I wanted to set up a subversion repository on this server.  I have not set up a subversion server before, and this process took me some time.

Background/Comparison with Git

It is a little tricky to set up an svn server and repository (much harder than setting up a git server and repository).

With git, a user merely has to have ssh access to the server in order for him to be able to use it as a git server.  He can create a repository using steps similar to these and move on.

It is possible to tunnel SVN connections through SSH using the svn+ssh protocol, as described here.  This method of access involves a layer of hassle on the client-side however, as unless you set up ssh private/public key authentication using an agent like pageant you will be stuck typing in your credentials numerous times for each request.  Tunneling through SSH is less convenient for SVN than it is for Git, as SVN is centralized and must therefore make more network requests to get anything done.

Git really only works well when each project or even module is in its own repository, as git does not provide sub-tree checkouts.  This means that you end up creating a repository for each new project you make.

Keeping track of all your repositories and the dependencies between the projects they contain can take some effort.

SVN works quite well with many projects in a single repository on the other hand.  You can ignore what other people are doing in their trees and check out only the tree you are interested in.

Because svn+ssh:// is not easy to use on the client-side, in this article we stick to straight svn:// protocol access.

This guide was written using FreeBSD 10.1-RC4-p1 and Subversion 1.8.10.


Here is a good preexisting article on the subject of setting up a subversion server.

Here is a helpful forum thread on the subject of setting up a subversion server.

I encountered a few difficulties using the above approaches, so below I explain the steps I used to set things up.

I knew I wanted to use the “svnserve” daemon to make my repository over the svn protocol. There is an alternate technique to make the repository available over http, which I did not do.

Below are the setup steps COPIED FROM the forum post above, with modifications by me.

I set a term in italics if it is my intention that you replace that term with your own value when you use these instructions.

FreeBSD Subversion Server-side Setup Steps

Setting up Subversion

1. Install subversion from ports.

# cd /usr/ports/devel/subversion
# make install clean

2. Decide where the files will be stored. I use /usr/local/var/svn.

# export SVN_ROOT=/usr/local/var/svn

3. Create a user and group svn.  This will be the user which the svnserve daemon will run as.

# pw groupadd svn
# pw adduser svn -g svn -s /usr/sbin/nologin

You may find it convenient to add your working user (say, joe) to the svn group.

sudo pw groupmod svn -m joe

4. Add any users that will use the repositories directly through the local filesystem to the svn group.

# pw groupmod svn -m user

5. Create a general repository format.  The defaults directory and subdirectories are used as a template for new subversion repositories which you create in the repos directory, or project which you create within a preexisting repository.

Note that in subversion you usually have “branches”, “tags”, and “trunk” directories at various levels of the repository hierarchy.  Subversion does not enforce any special properties of these directories, but this is a common convention that serves many people well.

# mkdir -p $SVN_ROOT/repos
# mkdir -p $SVN_ROOT/defaults/trunk
# mkdir $SVN_ROOT/defaults/branches
# mkdir $SVN_ROOT/defaults/tags

6. Make user svn own everything so that the svnserve daemon can do its work.

# chown -R svn:svn $SVN_ROOT

7.  Here what I do differs from other examples on the net.  Instead of putting all rc configuration in /etc/rc.conf, I put most of it in /usr/local/etc/rc.d/svnserve, so that I can use commands like

sudo service restart svnserve

and have everything configured properly without having to put extra flags on the command line.

Add this to /etc/rc.conf


Add this to /usr/local/etc/rc.d/svnserve


Comment out the existing lines setting these values.  Note that the –listen-port and –listen-host flags used in some examples are not necessary.  The port will default to 3690, which is what I want, and the server will bind to each hostname/ip associated with it (, local network ip, domain name, etc…), instead of any one ip address.

Setting up a Repository

Now let’s create an actual subversion repository and set it up.

1. Create a new repository called example.  We will import the default directory structure to this repository in a later step.

# svnadmin create $SVN_ROOT/repos/example

2. Change the permissions on the newly created files.

# chown -R svn:svn $SVN_ROOT/repos/example
# chmod -R g+w $SVN_ROOT/repos/example

3. Set svnserve permissions. Edit $SVN_ROOT/repos/example/conf/svnserve.conf.

anon-access = read
auth-access = write
password-db = passwd

The anon-access and auth-access settings are specific to what I want, if you want more or less restrictive access change them accordingly.

4. Edit the $SVN_ROOT/repos/example/conf/passwd file to grant users svnserve privileges.

testuser = testuser_password

Note that you just put a plaintext password in a file.  If this is inadequate for your security needs, look at svn+ssh (easier to set up on the server-side, cumbersome for the client).

5. THIS STEP WAS MISSING IN SOME OTHER GUIDES.  Grant users specific powers using the authz file in $SVN_ROOT/repos/example/conf/authz.  This authz is fairly well documented by internal comments — a primary functionality of it is granting users various levels of access to specific paths within the repo.  Here is a simple example setup giving testuser rw access and everyone read access to the entire repository.

testuser = rw
* = r

6. Change permissions on the configuration files to bolser security a bit.

# chown -R root:wheel $SVN_ROOT/repos/example/conf

Starting the SVN Server


# sudo service start svnserve

to bring your svn server online.

Testing your Setup

Let’s test that things are actually working by importing the basic directory structure into our new blank repository example.

# svn import $SVN_ROOT/defaults svn://localhost/example -m "importing directory structure"

Log in with the svnserve username and password you created above.  If you are successfully able to write this commit, you have a functioning svnserve setup!


It would be nice to make a script that did all this for you, but unfortunately I’m not sure how to script the in-place modification of /usr/local/etc/rc.d/svnserve which I did.

If you encounter any trouble, please leave a comment!


One thought on “Setting up an SVN server on FreeBSD.

  1. Is there a particular reason why you modified `rc.d` script ? You should be adding your `svnserve` to your `rc.conf(5)` instead.

    `rc.d` scripts are provided by packages are not supposed to be modified. Just in case you do need to modify them, better to update in the port (and submit changes to port maintainer), so next time you need to reinstall the port, your `rc.d` script changes will persist.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s