Installing a Subversion server on CentOS 8

We are going to use the server “svnserve” which is contained in the subversion package of CentOS. This package contains also the svnadmin tool for creating a subversion repositories.

Installation

dnf install subversion

Service configuration

The default location for Subversion (SVN) repositories is /var/svn. We are going to change it to /srv/subversion like this (as root):

mkdir /srv/subversion
nano /etc/sysconfig/svnserve
OPTIONS="-r /srv/subversion"

By default, svnserve is executed as root – holy cow! For security reasons, we’re going to change it to a different user. We edit the systemd unit file and add the following lines under the section “[Service]”:

nano /usr/lib/systemd/system/svnserve.service
[Service]
User=yolo
Group=yolo

You can create the user e. g. with useradd -m yolo.

Make sure that our “yolo” user can access /srv/subversion properly:

chown -R yolo:yolo /srv/subversion

Furthermore, another change is necessary due to the new user which executes the service: The directory /run/svnserve/ contains a file where the service stores its process ID. But the directory is only accessible by the root owner. Changing the file permissions with chown is NOT a good solution because this folder will be recreated after reboot and thus the old permissions will be restored. We have to change the entry in the appropriate configuration file which is responsible for the recreation of this folder (see man tmpfiles.d for details):

nano /usr/lib/tmpfiles.d/svnserve.conf
D /run/svnserve 0700 yolo yolo -

Now, we can start the service (and enable it if you want to start it automatically):

systemctl start svnserve
systemctl status svnserve
systemctl enable svnserve

Create a test repository

Use our “yolo” user which also runs the svnserve process for the following commands:

cd /srv/subversion
svnadmin create repo1

Configure user authentication:

cd repo1
nano conf/svnserve.conf
anon-access = none # disallow anonymous access completely
password-db = passwd # file with credetials

Add some credetials:

nano conf/passwd
user = pw

Check it out

The repository set-up is complete. Now, we should be able to check it out with a Subversion client on a remote computer:

svn co svn://HOST/repo1 --username USER