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.
- First install viewvc package.
sudo apt-get install viewvc
- 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.
- 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.
- 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
- 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
- Restart apache
$ sudo service apache2 restart
Now browse http://yoursvnserver.com/viewvc. Here is what you should see in ui:
- Click on repo1 and you should see files as shown below:
Please note that you must have created these files (using svn) as mentioned above so that they can appear here as list. - Clic on file1 and assuming we did two checkins on this file, here is how revision history should appear:
- If you click on “Diff to previous 1” then the diff ui will appear as shown below:
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.