How to install ViewVC for svn repository on Ubuntu Linux

ViewVC is a browser interface for cvs and subversion version control repositories. If you are using svn then its a great tool to browse your source code, see history and diffs of multiple file versions.

Here are the steps to setup ViewVC on Ubuntu Linux with Apache2 installed. These instructions assume that you have installed and setup svn already.

  1. First install viewvc package.
    sudo apt-get install viewvc
  2. These are the steps to install a test repository at /svn/repos/repo1
    sudo mkdir /svn
    sudo chown www-data /svn
    sudo -u www-data mkdir /svn/repos
    sudo -u www-data svnadmin create /svn/repos/repo1

    This will create an empty repository at /svn/repos/repo1. It should be owned by www-data as Apache runs as www-data and should be able to write here. I have also created file1.txt (2 revisions) and file2.txt in repo1 by checking out the source code.

  3. Change Apache conf file corresponding to svn and add these lines:
    Alias /viewvc-static /usr/lib/python2.4/site-packages/viewvc/templates-contrib/newvc/templates/docroot
    ScriptAlias /viewvc /usr/lib/viewvc/cgi-bin/viewvc.cgi

    This will setup http://yoursvnserver.com/viewvc as url for browsing repository.

  4. Add this config entry to /etc/viewvc/viewvc.conf at appropriate place:
    svn_roots = repo1: /svn/repos/repo1

    You can also add multiple svn repositories here by separating them with “,”. e.g.

    svn_roots = repo1: /svn/repos/repo1, repo2: /svn/repos/repo2
  5. Check if cgi module is enabled/loaded
    $ apache2ctl -M | grep cgi
     cgi_module (shared)
    

    If it is not loaded, then run the following to enable it (Thanks Eric for the suggestion):

    $ sudo a2enmod cgi
    
  6. Restart apache
    $ sudo service apache2 restart
    

    Now browse  http://yoursvnserver.com/viewvc. Here is what you should see in ui:
    svn-viewvc-home-page

  7.  Click on repo1 and you should see files as shown below:
    svn-viewvc-dir-file-listPlease note that you must have created these files (using svn) as mentioned above so that they can appear here as list.
  8. Clic on file1 and assuming we did two checkins on this file, here is how revision history should appear:
    svn-viewvc-file-revision-logs
  9. If you click on “Diff to previous 1” then the diff ui will appear as shown below:
    svn-viewvc-file-revisions-diff

 

ViewVC is a great ui tool and probably indispensable if you are using svn or cvs for source code version control.  Even though you can achieve most of the viewvc functionaries using command line svn command, but viewvc ui is lot more convenient for source code browsing.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments