Install Subversion (SVN) Server

I primarily use Git now for source control, but I sometime still need to set up subversion servers for different organizations. These are the steps that I do to install…

Install the necessary packages:

sudo apt-get install -y subversion apache2 libapache2-mod-svn

Create the directory of the subversion repository:

sudo mkdir -p /export/svn
sudo svnadmin create /export/svn
sudo chown -R www-data:www-data /export/svn

Configure Apache

cat > /tmp/dav_svn.conf << EOF
  <Location /svn>
     DAV svn
     SVNPath /export/svn
     AuthType Basic
     AuthName "Subversion Repository"
     AuthUserFile /etc/subversion/passwd
     Require valid-user
  </Location>
EOF

sudo mv /tmp/dav_svn.conf /etc/apache2/mods-available/dav_svn.conf
sudo chown root:root /etc/apache2/mods-available/dav_svn.conf

Restart Apache

sudo service apache2 restart

Add SVN Users as needed

sudo htpasswd -c /etc/subversion/passwd username