Setting up Subversion Version control in Ubuntu

Subversion logoWhen developing a project, you may want to keep a version control of all your files so that you can easily revert to an earlier page (or the previous revision) to fix any bugs or in the event that someone accidentally deleted your files.

In Ubuntu, the easiest way to do version control is to set up a Subversion (SVN) server.

Install SVN and Apache

sudo apt-get install subversion libapache2-svn

Next, we are going to create a directory to hold your repository.

sudo svnadmin create /var/lib/svn

Give apache the access right to the repository

sudo chown -R www-data:www-data /var/lib/svn
sudo chmod 770 -R /var/lib/svn

Configure Apache for SVN access

gksu gedit /etc/apache2/mods-available/dav_svn.conf

Uncomment the codes by removing the ‘#’ in front of the following lines:

<Location /svn>

DAV svn

AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd

<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>

If you have only one repository for your SVN, uncomment the following line

SVNPath /var/lib/svn

Else if you are setting up multiple repositories, uncomment this line

SVNParentPath /var/lib/svn

Remember that at any time, only SVNPath or SVNParentPath is uncommented. Do not uncomment both at the same time.

Create a password for your username

sudo htpasswd -cm /etc/apache2/dav_svn.passwd yourusername

Restart apache

sudo /etc/init.d/apache2 restart

Now open your browser and go to http://localhost/svn. If you see the following, the your installation is successful.

Subversion

Importing your project into SVN

You have successfully installed and configured SVN, now we need to import our project files to the SVN.

sudo apt-get install rapidsvn

Go to Applications->Programming->RapidSVN

In the RapidSVN, go to Repository->Import

In the window, enter the following:

rapidsvn-import

Click OK. Enter your username and password. Your project should be in the SVN now.

Damien Oh is the owner and chief editor of Make Tech Easier

Tags: , , ,

 

Enjoyed the article? Subscribe to Make Tech Easier today to get your daily updates of technology tutorials, tips and tricks.

Enter your email:

8 Responses

  • Scott McHugh says:

    Thanks for the article! I noticed one quick change due to renaming of htpasswd2 in apache-utils- when configuring the password, the line should be updated from:

    sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd yourusername

    to:
    sudo htpasswd -cm /etc/apache2/dav_svn.passwd yourusername

    Best,
    -Scott

    Reply

    Damien Reply:

    Thanks for informing. I have make the changes.

    Reply

  • Pavlos says:

    Hi i just want to setup subversion for the first time.I followed your howto but when i go to http://localhost/svn i get:
    Forbidden
    You don’t have permission to access /svn on this server.
    Apache/2.2.11 (Ubuntu) DAV/2 SVN/1.5.4 Server at localhost Port 80
    Can i do something to fix it?

    Reply

    Damien Reply:

    Did you set the correct permission for the svn folder:

    sudo chown -R www-data:www-data /var/lib/svn
    sudo chmod 770 -R /var/lib/svn

    Reply

  • Pavlos says:

    Thanks for your reply.I created /home/pavlos/Documents/programming/code/svn as mine svn folder with the permissions below :
    $ sudo ls -lah /home/pavlos/Documents/programming/code/svn
    [sudo] password for pavlos:
    total 32K
    drwxrwx— 6 www-data www-data 4.0K 2009-08-17 22:01 .
    drwxrwxrwx 11 pavlos pavlos 4.0K 2009-08-23 22:37 ..
    drwxr-xr-x 2 root root 4.0K 2009-08-17 22:01 conf
    drwxr-sr-x 6 root root 4.0K 2009-08-17 22:06 db
    -r–r–r– 1 root root 2 2009-08-17 22:01 format
    drwxr-xr-x 2 root root 4.0K 2009-08-17 22:01 hooks
    drwxr-xr-x 2 root root 4.0K 2009-08-17 22:01 locks
    -rw-r–r– 1 root root 229 2009-08-17 22:01 README.txt

    The strange thing is that with SVNPath is working ok but with SVNParentPath no.

    Reply

    Walleye Reply:

    Try to add this line in your dav_svn.conf:

    SVNParentPath on

    This worked fine for me

    Reply

  • Walleye says:

    Ups.. following is correct:

    SVNListParentPath on

    Reply

  • Walleye says:

    sry, it is:

    SVNListParentPath on

    Reply

Leave a Comment




 

Sign in with Twitter

Comment

Please Note: Comments maybe under moderation after you submit your comments so there is no need to resubmit your comment again