In this blog post, we will look at how you can Install SVN Server on Ubuntu 20.04|18.04|16.04 & Debian 10|9. Apache Subversion (SVN) is a popular open-source software versioning and revision control system released under the Apache License. SVN is used by Software Developers to maintain historical and current versions of source code, documentation, web pages e.t.c.
Subversion has enjoyed widespread adoption over the years both in the corporate & Open Source arena.
Step 1: Install SVN Server n Ubuntu / Debian
SVN Server requires Apache web server, which can be installed by running the command:
sudo apt update
sudo apt -y install apache2 apache2-utils
Then install Apache SVN:
sudo apt -y install vim tree subversion libsvn-dev libapache2-mod-svn subversion-tools
Enable Apache modules required by SVN:
sudo a2enmod dav dav_svn
sudo systemctl restart apache2
Edit SVN apache configuration file and make changes similar to below:
sudo tee /etc/apache2/mods-enabled/dav_svn.conf<<EOF
Alias /svn /var/lib/svn
<Location /svn>
DAV svn
SVNParentPath /var/lib/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
EOF
Check configuration syntax
$ sudo apachectl -t
Syntax OK
Then restart apache2
service:
sudo systemctl restart apache2
Step 2: Create SVN users
We specified in SVN Apache configuration file that user aunthentication information be saved on /etc/apache2/dav_svn.passwd
. Let’s create our admin Subversion user.
sudo htpasswd -cm /etc/apache2/dav_svn.passwd admin
Provide your admin user password:
New password: <ENTER PASSWORD>
Re-type new password:<CONFIRM PASSWORD>
Adding password for user admin
Used Options:
-c : Create a new file.
-m Force MD5 encryption of the password (default).
When adding other users, don’t user the -c option, just pass -m to modify the file.
sudo htpasswd -m /etc/apache2/dav_svn.passwd user1
sudo htpasswd -m /etc/apache2/dav_svn.passwd user2
sudo htpasswd -m /etc/apache2/dav_svn.passwd user1
Step 3: Create an SVN Repository
Now that you have SVN installed, you need to create a new repository for it. We will put our repository inside /var/lib/svn/ directory.
sudo mkdir -p /var/lib/svn/
Create a repository using the command svnadmin
Subversion repository administration tool.
sudo svnadmin create /var/lib/svn/<repo-name>
E.g
sudo svnadmin create /var/lib/svn/repo1
This will create a new repository called payments-gateway
with below tree structure.
$ tree /var/lib/svn/repo1
/var/lib/svn/repo1
|-- README.txt
|-- conf
| |-- authz
| |-- hooks-env.tmpl
| |-- passwd
| `-- svnserve.conf
|-- db
| |-- current
| |-- format
| |-- fs-type
| |-- fsfs.conf
| |-- min-unpacked-rev
| |-- revprops
| | `-- 0
| | `-- 0
| |-- revs
| | `-- 0
| | `-- 0
| |-- transactions
| |-- txn-current
| |-- txn-current-lock
| |-- txn-protorevs
| |-- uuid
| `-- write-lock
|-- format
|-- hooks
| |-- post-commit.tmpl
| |-- post-lock.tmpl
| |-- post-revprop-change.tmpl
| |-- post-unlock.tmpl
| |-- pre-commit.tmpl
| |-- pre-lock.tmpl
| |-- pre-revprop-change.tmpl
| |-- pre-unlock.tmpl
| `-- start-commit.tmpl
`-- locks
|-- db-logs.lock
`-- db.lock
10 directories, 28 files
Set the owner of the directory /var/lib/svn to www-data
user & group.
sudo chown -R www-data:www-data /var/lib/svn
sudo chmod -R 775 /var/lib/svn
Finally access SVN web interface:
http://server_ip_or_hostname/svn/<reponame>
# For me this will be http://server_ip_or_hostname/svn/repo1
Login with created username and password.


You have completed the steps to Install SVN Server on Ubuntu 18.04 / Debian 9. Check Apache Subversion Documentation to learn more about how to use SVN.