How to setup Subversion (SVN) on Debian

Post Reply
User avatar
isscbta
Team Member
Posts: 150
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 18 times
Been thanked: 3 times

This guide explains how to set up SVN (Subversion) repository management on a Debian server running myVesta.

Step 1: Create the svn user with SSH access

In the myVesta panel, create a new user named svn and grant SSH access.
We will execute some commands as root and others as svn.

Step 2: Install Subversion as root

Code: Select all

apt update
apt install subversion
svn --version # Verify SVN installation
Step 3: Create Repository Folders and Set Permissions

Code: Select all

mkdir -p /srv/svn/repos
mkdir -p /var/log/svnserve
mkdir -p /run/svnserve
chown svn:svn /srv/svn/repos
chown svn:svn /var/log/svnserve
chown svn:svn /run/svnserve
Explanation:
  • /srv/svn/repos: Repository storage location
  • /var/log/svnserve: Directory for svnserve logs
  • /run/svnserve: Runtime directory for the daemon
Step 4: Initialize the SVN Repository as svn User

Switch to the svn user and create the repository:

Code: Select all

svnadmin create /srv/svn/repos/myapp
chown -R svn:svn /srv/svn/repos/myapp
Configure the repository:

Code: Select all

mcedit /srv/svn/repos/myapp/conf/svnserve.conf
Uncomment:

Code: Select all

[general]
anon-access = none
auth-access = write
password-db = passwd
Edit user credentials:

Code: Select all

mcedit /srv/svn/repos/myapp/conf/passwd
Add users in the format:

Code: Select all

[users]
username = password
Step 5: Configure the svnserve System Service as root

Create the service unit:

Code: Select all

mcedit /etc/systemd/system/svnserve.service
Paste the following content:

Code: Select all

[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target

[Service]
Type=forking
RuntimeDirectory=svnserve
PIDFile=/run/svnserve/svnserve.pid
EnvironmentFile=/etc/default/svnserve
ExecStart=/usr/bin/svnserve $DAEMON_ARGS
User=svn
Group=svn
KillMode=control-group
Restart=on-failure

[Install]
WantedBy=multi-user.target
Create the environment configuration:

Code: Select all

mcedit /etc/default/svnserve
Add the following line:

Code: Select all

DAEMON_ARGS="--daemon --pid-file /run/svnserve/svnserve.pid --root /srv/svn/repos --log-file /var/log/svnserve/svnserve.log"
Step 6: Reload Systemd and Start the SVN Daemon

Code: Select all

systemctl daemon-reload
systemctl enable svnserve
systemctl start svnserve
systemctl status svnserve
Step 7: Open the Firewall Port

Allow SVN traffic on TCP port 3690:

Code: Select all

v-add-firewall-rule 'ACCEPT' '0.0.0.0/0' '3690' 'TCP' 'svn'
Final Notes
  • Replace myapp with your preferred repository name.
  • Use passwd to manage access credentials securely.
  • Always test your configuration by connecting to svn://your-server/myapp.
  • Monitor logs at /var/log/svnserve/svnserve.log for troubleshooting.
  • This setup provides a clean and maintainable SVN server with access control and service management.
Post Reply