Installing Subversion server on FreeBSD using svnserve

There are lots of guides on net that help you out on installing subversion server on FreeBSD, but most of them describe installing subversion server with Apache and mod_dav. Apache is used to access your subversion repository using http or https. But this becomes a problem if you are using one of the alternate servers (nginx ot lighttpd), or would not like to install any web server. In that case, it is much easier to use “svnserve” daemon to access the repository. This is how I went about doing it after updating my ports tree:

cd /usr/ports/devel/subversion; make -DBATCH all install clean
or alternatively use the new pkgng ( to install binaries.Search for the right package using
pkg search subversion
and then install the latest version(1.8.5 as on date) available using
pkg install subversion-1.8.5
Using binary packages is far easier and faster, but you loose the flexibility of ports. You can also install subversion through the older pkg_add tools if it’s still supported in your release.

Once you have installed the subversion through either of the methods, create a user for svn:
pw groupadd svn; pw adduser svn -g svn -s /usr/sbin/nologin
Create a home directory for all repository:
mkdir -p /usr/home/svn/repos; chown -R svn:svn /usr/home/svn
Add entries in /etc/rc.conf to run svnserve daemon on startup
echo 'svnserve_enable="YES"' >> /etc/rc.conf ; echo 'svnserve_data="/usr/home/svn/repos"' >> /etc/rc.conf
Now start the svnserve daemon either by
service svnserve start
or by
/usr/local/etc/rc.d/svnserve start
Check if svnserve is running by
sockstat |grep svnserve
If it is running on port 3690, you have successfully installed subversion and is accessible through the svnserve daemon.

Now create the repositories in svn. Remember, each repository has its own configuration and access control. Once you create a repository using
svnadmin create /usr/home/svn/repos/myfirstrepo
the newly created repository is now located at /usr/home/svn/repos/myfirstrepo. You will need to modify three files for the repository to be accessible for you. Under /usr/home/svn/repos/myfirstrepo/conf, you will find authz, passwd & svnserve.conf files. In passwd file, create username and password in the following syntax:
username = password. Place each user in a new line. In the authz file, the simplest way is to set the access control for the repository itself, although there are a lot of combinations available for access control. I simply use this:
username = rw

You can use r for read access, w for write access and blank for no access. For the svnserve.conf file, under the [general] section, set the following three lines:
anon-access = none
auth-access = read
auth-access = write

This should replace any existing similar values.

You should now be ready to access the repository from a svn client. Just remember that you need to access the repository using svn:///myfirstrepo scheme. Hope it works out for you as well.



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 )

Facebook photo

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

Connecting to %s