
This article provides a guide demonstrating how to deploy Subversion on Debian VPS.
What is Subversion?
Apache Subversion (SVN) is an open-source version control system used to track changes to source code, configuration files, documents, and other files over time.
Like Git, it allows you to maintain a complete revision history, collaborate with other developers, and restore previous versions of files.
How Subversion works
Subversion uses a centralized version control model, meaning a single central repository maintains the authoritative version history.
Developers check out files from the central repository, make changes locally, and commit those changes back to the server.
Subversion vs. Git
| Feature | Subversion (SVN) | Git |
|---|---|---|
| Architecture | Centralized | Distributed |
| Repository history | Central server | Local and remote |
| Offline commits | No | Yes |
| Revision identifiers | Sequential numbers | Commit hashes |
| Branching | Repository-based | Lightweight |
| Directory-level checkout | Native | Limited through sparse checkout |
| File locking | Native | Optional through extensions such as Git LFS |
| Granular directory permissions | Native | Typically requires additional tooling |
| Single server dependency | Yes | No |
Common Subversion commands
# Check out a repository svn checkout https://svn.example.com/project # Retrieve the latest changes svn update # Check modified files svn status # View changes svn diff # Add a file svn add filename.php # Commit changes svn commit -m "Updated configuration" # View revision history svn log # Revert local changes svn revert filename.php
Where Subversion is useful
- Centralized server configuration management.
- Enterprise software development.
- Projects requiring directory-level access permissions.
- Repositories containing large binary files.
- Workflows requiring exclusive file locking.
- Maintaining legacy software projects.
Is Subversion still worth using?
Yes! Subversion remains a viable version control system, particularly when centralized control and granular permissions are important.
Official website: subversion.apache.org
Notes
This guide covers Debian 12 (bookworm) and Debian 13 (trixie). The commands are the same on both. It sets up a central Subversion server with one of three access methods, then covers repository layout, access control, hooks, backups and troubleshooting.
Compare Debian VPS Plans
How to Deploy Subversion on Debian VPS
To deploy Subversion on Debian VPS, follow the steps outlined below:
See Also: Install Coder on AlmaLinux VPS and Connect Workspace to VS Code (5 Minute Quick-Start Guide)
-
Choose an Access Method
Method URL scheme Transport security Auth backend Best for Apache + moddavsvn https://TLS htpasswd, LDAP, etc. Production, firewalled clients, web browsing of repos svnserve daemon svn://None (plaintext unless SASL encryption) passwdfile or SASLLAN/VPN, quickest setup svnserve over SSH svn+ssh://SSH SSH keys Small teams that already use SSH keys Recommendation: use Apache over HTTPS for anything that faces the internet. Sections 4β6 cover each method separately, so pick one. Running more than one against the same repository works, but every process that writes to it needs a shared group and umask.
-
Prerequisites
- A Debian 12/13 VPS with a sudo-capable user
- A DNS record (e.g.
svn.example.com) pointing at the VPS, which the HTTPS method needs - Open ports: 443/80 (Apache), 3690 (svnserve) or 22 (SSH)
Update the system:
sudo apt update && sudo apt full-upgrade -y sudo apt install -y subversion svnadmin --version | head -n1
-
Create the Repository Root and a Repository
Keep every repository under one parent directory.
/srv/svnis the conventional choice.sudo mkdir -p /srv/svn sudo svnadmin create --fs-type fsfs /srv/svn/myproject
Create the standard
trunk/branches/tagslayout in a single commit:sudo svn mkdir -m "Initial repository layout" \ file:///srv/svn/myproject/trunk \ file:///srv/svn/myproject/branches \ file:///srv/svn/myproject/tags
To import an existing source tree, use this instead:
sudo svn import /path/to/source file:///srv/svn/myproject/trunk -m "Initial import"
Repository directory structure:
/srv/svn/myproject/ βββ conf/ # svnserve.conf, passwd, authz (svnserve only) βββ db/ # FSFS revision data βββ hooks/ # *.tmpl hook templates βββ locks/ βββ format
Ownership is set in the section for your chosen access method. Donβt skip that step. Wrong ownership is the most common cause of failed commits.
See Also: Integrate Jitsi Meet with Moodle for Elearning Video Conferencing
-
Method A: Apache + moddavsvn over HTTPS (Recommended)
-
Install packages
sudo apt install -y apache2 libapache2-mod-svn apache2-utils certbot python3-certbot-apache sudo a2enmod dav dav_svn authz_svn ssl headers
-
Set repository ownership
Apache runs as
www-data, so it must own the repository:sudo chown -R www-data:www-data /srv/svn sudo chmod -R g+rwX /srv/svn
-
Create a plain HTTP vhost (needed to issue the certificate)
/etc/apache2/sites-available/svn.conf:ServerName svn.example.com DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/svn_error.log CustomLog ${APACHE_LOG_DIR}/svn_access.log combinedsudo a2ensite svn.conf sudo apachectl configtest && sudo systemctl reload apache2 sudo certbot --apache -d svn.example.com --redirect
Certbot creates
/etc/apache2/sites-available/svn-le-ssl.confand adds an HTTPβHTTPS redirect to the port-80 vhost. -
Add the SVN location to the SSL vhost only
Edit
/etc/apache2/sites-available/svn-le-ssl.confand add this inside:DAV svn SVNParentPath /srv/svn SVNListParentPath On # Authentication AuthType Basic AuthName "Subversion Repositories" AuthUserFile /etc/apache2/svn.htpasswd Require valid-user # Path-based authorization AuthzSVNAccessFile /etc/apache2/svn-authz # Performance SVNCacheFullTexts on SVNCacheTextDeltas on SVNInMemoryCacheSize 65536 # Apache >= 2.4.54 defaults LimitRequestBody to 1 GiB; lift it for large binaries LimitRequestBody 0 Header always set Strict-Transport-Security "max-age=31536000"SVNInMemoryCacheSizeis in KiB, so 65536 means 64 MiB per Apache process. Lower it on small VPS plans. -
Create users
sudo htpasswd -c -B /etc/apache2/svn.htpasswd alice # -c only for the first user sudo htpasswd -B /etc/apache2/svn.htpasswd bob sudo chown root:www-data /etc/apache2/svn.htpasswd sudo chmod 640 /etc/apache2/svn.htpasswd
-Bstores bcrypt hashes. Remove a user withhtpasswd -D /etc/apache2/svn.htpasswd bob. -
Define access rules
/etc/apache2/svn-authz:[groups] devs = alice, bob readers = carol # Default: deny everything [/] * = [myproject:/] @devs = rw @readers = r # Example: lock down a subtree [myproject:/tags] @devs = r alice = rw
sudo chown root:www-data /etc/apache2/svn-authz sudo chmod 640 /etc/apache2/svn-authz sudo apachectl configtest && sudo systemctl reload apache2
The authz file is re-read on every request, so you donβt need to reload Apache after editing it.
-
Firewall
sudo ufw allow "Apache Full" # 80 + 443
Repository URL:
https://svn.example.com/svn/myproject
-
-
Method B: svnserve Daemon (
svn://)svn://traffic is unencrypted, and thepasswdfile stores passwords in plaintext. Use this method only on a private network or VPN, or put a tunnel in front of it.See Also: π Deploy Odoo on Rocky Linux VPS
-
Create a service account and set ownership
sudo adduser --system --group --home /srv/svn --no-create-home svn sudo chown -R svn:svn /srv/svn sudo chmod -R g+rwX /srv/svn
-
Shared auth files
Keep the auth files outside the served root so all repositories can share them:
sudo mkdir -p /etc/svnserve
/etc/svnserve/passwd:[users] alice = StrongPassword1 bob = StrongPassword2
/etc/svnserve/authzuses the same syntax as section 4.6.sudo chown -R root:svn /etc/svnserve sudo chmod 750 /etc/svnserve sudo chmod 640 /etc/svnserve/*
-
Configure each repository
/srv/svn/myproject/conf/svnserve.conf:[general] anon-access = none auth-access = write password-db = /etc/svnserve/passwd authz-db = /etc/svnserve/authz realm = Rad SVN
-
systemd unit
Debian doesnβt ship a unit for svnserve. Create
/etc/systemd/system/svnserve.service:[Unit] Description=Subversion server (svnserve) After=network-online.target Wants=network-online.target [Service] Type=simple User=svn Group=svn UMask=0002 ExecStart=/usr/bin/svnserve --daemon --foreground \ --root=/srv/svn \ --listen-port=3690 \ --memory-cache-size=64 \ --cache-txdeltas=yes \ --cache-fulltexts=yes Restart=on-failure # Hardening NoNewPrivileges=yes PrivateTmp=yes ProtectSystem=strict ProtectHome=yes ReadWritePaths=/srv/svn ReadOnlyPaths=/etc/svnserve [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable --now svnserve sudo systemctl status svnserve sudo ss -ltnp | grep 3690
-
Firewall
Restrict the port to trusted sources where you can:
sudo ufw allow from 203.0.113.0/24 to any port 3690 proto tcp
Repository URL:
svn://svn.example.com/myproject. The path is relative to--root.
-
-
Method C: svnserve over SSH (
svn+ssh://)This method uses a single locked-down
svnaccount. Each developerβs key is forced to runsvnservein tunnel mode under their own identity, so nobody gets a shell.sudo adduser --system --group --home /home/svn --shell /bin/sh svn sudo chown -R svn:svn /srv/svn sudo -u svn mkdir -p /home/svn/.ssh sudo -u svn touch /home/svn/.ssh/authorized_keys sudo chmod 700 /home/svn/.ssh && sudo chmod 600 /home/svn/.ssh/authorized_keys
Add one line per developer to
/home/svn/.ssh/authorized_keys:command="/usr/bin/svnserve -t -r /srv/svn --tunnel-user=alice",restrict ssh-ed25519 AAAA... alice@laptop command="/usr/bin/svnserve -t -r /srv/svn --tunnel-user=bob",restrict ssh-ed25519 AAAA... bob@desktop
restrictdisables port, agent and X11 forwarding and PTY allocation.--tunnel-usersets the commit author name. Path-based authorization still usesauthz-dbfromsvnserve.conf, so leavepassword-dbunset for this method.- Because of
-r /srv/svn, clients use paths relative to the root.
Repository URL:
svn+ssh://svn@svn.example.com/myproject -
Client Usage
On a workstation, install the client with
sudo apt install subversion(TortoiseSVN on Windows, or Homebrewsubversionon macOS).See Also: π How to Install and Run Netdata on AlmaLinux VPS (5 Minute Quick-Start Guide)
# Check out trunk svn checkout https://svn.example.com/svn/myproject/trunk myproject cd myproject # Day-to-day svn status svn add newfile.php svn commit -m "Add newfile" svn update svn log -l 10 svn diff -r PREV # Branch and tag (server-side cheap copies) svn copy ^/trunk ^/branches/feature-x -m "Create feature-x branch" svn copy ^/trunk ^/tags/1.0.0 -m "Tag 1.0.0" # Merge a branch back into trunk (from a trunk working copy) svn merge ^/branches/feature-x svn commit -m "Merge feature-x"
-
Hooks
Hooks live in
/srv/svn//hooks/. They must be executable, owned by the service user, and must not depend onPATH, because they run with an empty environment.Allow log-message edits (
hooks/pre-revprop-change):#!/bin/sh ACTION="$5" PROPNAME="$4" if [ "$ACTION" = "M" ] && [ "$PROPNAME" = "svn:log" ]; then exit 0 fi echo "Only svn:log may be modified." >&2 exit 1
Require a commit message (
hooks/pre-commit):#!/bin/sh REPOS="$1"; TXN="$2" LOG=$(/usr/bin/svnlook log -t "$TXN" "$REPOS") if [ -z "$(printf '%s' "$LOG" | tr -d '[:space:]')" ]; then echo "Commit message required." >&2 exit 1 fi exit 0
sudo chmod 755 /srv/svn/myproject/hooks/pre-revprop-change /srv/svn/myproject/hooks/pre-commit sudo chown www-data:www-data /srv/svn/myproject/hooks/* # or svn:svn for methods B/C
-
Backups
You can back up a repository two ways. Use both.
svnadmin hotcopy: a fast, consistent physical copy, best for restoring the same Subversion version.svnadmin dump: a portable logical dump that survives version upgrades and migrations.
/usr/local/sbin/svn-backup.sh:#!/usr/bin/env bash set -euo pipefail SRC=/srv/svn DEST=/var/backups/svn KEEP_DAYS=14 STAMP=$(date +%F) mkdir -p "$DEST/hotcopy" "$DEST/dumps/$STAMP" for repo in "$SRC"/*/; do repo=${repo%/} name=$(basename "$repo") [ -f "$repo/format" ] || continue svnadmin hotcopy --incremental "$repo" "$DEST/hotcopy/$name" svnadmin dump --quiet --deltas "$repo" | gzip -6 > "$DEST/dumps/$STAMP/$name.dump.gz" done find "$DEST/dumps" -mindepth 1 -maxdepth 1 -type d -mtime +"$KEEP_DAYS" -exec rm -rf {} +sudo chmod 750 /usr/local/sbin/svn-backup.sh echo '30 2 * * * root /usr/local/sbin/svn-backup.sh' | sudo tee /etc/cron.d/svn-backup
Sync
/var/backups/svnto off-server storage (rsync, restic, S3, etc.). A backup kept only on the same VPS isnβt a backup.See Also: π How to Deploy Navidrome on Ubuntu VPS
Restore from a dump:
sudo svnadmin create /srv/svn/myproject gunzip -c myproject.dump.gz | sudo svnadmin load /srv/svn/myproject sudo chown -R www-data:www-data /srv/svn/myproject # adjust owner per method
Migrate from a remote server you have no shell access to:
svnrdump dump https://old.example.com/svn/myproject | gzip > myproject.dump.gz
-
Maintenance
# Integrity check (run periodically or after hardware issues) sudo svnadmin verify /srv/svn/myproject # Pack completed FSFS shards (fewer files, better performance) sudo -u www-data svnadmin pack /srv/svn/myproject # Upgrade repo format after a major Debian/Subversion upgrade sudo -u www-data svnadmin upgrade /srv/svn/myproject # Remove stale transactions left by aborted commits sudo svnadmin lstxns /srv/svn/myproject sudo -u www-data svnadmin rmtxns /srv/svn/myproject $(sudo svnadmin lstxns /srv/svn/myproject) # Repository info sudo svnadmin info /srv/svn/myproject
svnadmin upgradeonly bumps the repository format. To pick up every on-disk improvement, do a fulldumpand thenloadinto a fresh repository. -
Troubleshooting
Symptom Likely cause Fix Can't open file '.../db/txn-current-lock': Permission deniedWrong owner (often root after svn mkdir/importviafile://)chown -R www-data:www-data /srv/svn/(orsvn:svn)HTTP 403 Forbiddenon checkoutauthz rule denies the path, or repo name in the section doesnβt match the directory Check [repo:/path]sections and the[/]defaultHTTP 401loopWrong AuthUserFilepath or htpasswd unreadable bywww-datals -l /etc/apache2/svn.htpasswd; checksvn_error.logCould not open the requested SVN filesystemSVNParentPathmismatch, or URL includes the wrong segmentURL should be /svn/, not/svn/srv/svn/E170013: Unable to connectFirewall, or service not listening ss -ltnp,ufw status, provider firewallE220001: Item is not readableauthz denies read on part of the path Grant rat the needed levelLarge commits fail with 413LimitRequestBodySet LimitRequestBody 0in thesvnserve: Authorization failedsvnserve.confpaths wrong, orsvnuser canβt read/etc/svnserve/*Check permissions; journalctl -u svnserveHook fails with command not foundHooks run with an empty PATHUse absolute paths ( /usr/bin/svnlook)Logs:
sudo tail -f /var/log/apache2/svn_error.log sudo journalctl -u svnserve -f
-
Hardening Checklist
- Serve only over HTTPS or SSH on public interfaces. Restrict
svn://with firewall rules. - Set
[/] * =in authz as a default-deny, then grant access explicitly. - Use bcrypt (
htpasswd -B) and keep auth files at mode640, owned byroot:. - Add
fail2banwith theapache-authjail to slow down brute-force attempts on Basic auth. - Put
/srv/svnon a filesystem with enough free inodes. Unpacked FSFS repositories create one file per revision. - Verify repositories and test a restore on a schedule, not only when something breaks.
- Keep
unattended-upgradesenabled for security patches to Apache and Subversion.
- Serve only over HTTPS or SSH on public interfaces. Restrict
See Also: How to Install BeAdmin Control Panel on Ubuntu VPS
Conclusion
You now know how to deploy Subversion on Debian VPS.









