How to Install and Configure Subversion Server on Ubuntu 13.04 Server

Subversion is a free and open-source version control system (VCS). It manages files and directories, and the changes made to them over time. This allows you to recover older versions of your data or examine the history of how your data changed.

VC

Subversion can operate across networks, which allows it to be used by people on different computers. Subversion is used by developers, and advanced users who need the very latest changes to the software (before releases occur).

Install Subversion

On Ubuntu 13.04, perform the following to install:

sk@server:~$ sudo apt-get install subversion libapache2-svn apache2

Configure Subversion

Create a directory for where you want to keep your subversion repositories:

sk@server:~$ sudo mkdir /subversion
sk@server:~$ sudo chown -R www-data:www-data /subversion/

Open the subversion config file dav_svn.conf and add the lines at the end as shown below. Comment or delete all the other lines in the config file:

sk@server:~$ sudo nano /etc/apache2/mods-enabled/dav_svn.conf 
[...]
#</Location>
<Location /subversion>
DAV svn
SVNParentPath /subversion
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>

Now create a SVN user using the following command. Here I create a new SVN user called sk with password ubuntu:

sk@server:~$ sudo htpasswd -cm /etc/apache2/dav_svn.passwd sk
New password: 
Re-type new password: 
Adding password for user sk

Use -cm parameter for the first time only, you can create another user with only -m parameter.

Create Subversion repository called unixmen.repo under /subversion directory:

sk@server:~$ cd /subversion/
sk@server:/subversion$ sudo svnadmin create unixmen.repo

Restart Apache service:

sk@server:~$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                 ... waiting                                                             [ OK ]

Test Subversion

Open the browser and navigate to http://ip-address/subversion/unixmen.repo. Enter the SVN username and password which you have created in the earlier step. In my case, username is sk and password is ubuntu.

unixmen.repo - Revision 0: - - Mozilla Firefox_005

Now you will able to access your repository.

Disable Anonymous Access

Open the file svnserve.conf file and make the changes as shown below:

sk@server:~$ sudo nano /subversion/unixmen.repo/conf/svnserve.conf 

[...]
## Uncomment and set to 'none' ##
anon-access = none
[...]
## uncomment ##
authz-db = authz
[...]

Create additional Directories(Links) in Subversion Repository

Create one or more directories:

sk@server:~$ sudo mkdir templates
sk@server:~$ cd templates/
sk@server:~/templates$ sudo mkdir updates
sk@server:~/templates$ sudo mkdir patches

Now import them to your repository:

sk@server:/templates$ sudo svn import -m 'Initial import' /templates/ http://192.168.1.200/subversion/unixmen.repo/
Authentication realm: <http://192.168.1.200:80> Subversion Repository
Password for 'root': 
Authentication realm: <http://192.168.1.200:80> Subversion Repository
Username: sk
Password for 'sk': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <http://192.168.1.200:80> Subversion Repository

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/home/sk/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? 
Please type 'yes' or 'no': yes
Adding         updates
Adding         patches

Committed revision 1.

Now check for the changes in your repository. Navigate to http://192.168.1.200/subversion/unixmen.repo. You will see the newly created directories in your repositories.

unixmen.repo - Revision 1: - - Mozilla Firefox_006

That’s it.