How to Install SVN Server on Ubuntu 20.04 LTS & 21.10
SVN offers secure SSL connection with user based authentication as well. You can give specific permission to users. You can also set up your own firewall on top of it to make it even more secure.
This article will help you for step-by-step setup of Subversion (SVN) server on Ubuntu 20.04 LTS & 21.10 systems.
Step 1 — Install Apache
SVN run over Apache HTTP server. So we need to install Apache first.
sudo apt-get update
sudo apt-get install apache2
Step 2 — Install SVN Server
Now we need to install SVN server and dependencies.
sudo apt-get install subversion
Step 3— Install Dependencies
We also need to install SVN dependencies and Apache mod for SVN.
sudo apt-get libapache2-mod-svn libapache2-svn libsvn-dev
After installation, we need to enable the Apache mod and restart the Apache server.
sudo a2enmod dav dav_svn
sudo service apache2 restart
Step 4— Creating your first SVN Repository
Create a new directory as base directory for all your repositories. Then create your new repository.
sudo mkdir -p /var/www/svn/
sudo svnadmin create /var/www/svn/myrepo
Step 5— Setup Directory Permissions
We need to configure correct permission to base directory
sudo chown -R www-data:www-data /var/www/svn
sudo chmod -R 775 /var/www/svn
Step 6— User Authentication
In this example, I am going with configure user authentication for SVN repositories. First, create a config file:
sudo touch /etc/apache2/dav_svn.passwd
Now add new user:
sudo htpasswd -m /etc/apache2/dav_svn.passwd myuser
Then it will ask for the password.
New Password: <Enter Your Password>
Re-type new password: <Confirm Your Password>
Step 7— Configure Apache for Subversion
We enabled SVN mod in Step 3 which created sample config file /etc/apache2/mods-enabled/dav_svn.conf
sudo nano /etc/apache2/mods-enabled/dav_svn.conf
Change the config as follows:
<Location /svn> # https://domain.com/svn
DAV svn
SVNParentPath /var/www/svn # svn base repo directory
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
Now restart the Apache2
sudo service apache2 restart
Yay! It's Done
Open the http://yourdomain/svn in your browser, and it will ask you for the user password.