How to Install and Configure ViewVC for Subversion on CentOS

Another alternative for subversion repositories web viewer is ViewVC. Just like WebSVN, viewvc having many useful features such as viewing subversion repositories, directories, to view change log listings and it can display specific versions of files as well as diffs between those versions. At the time of this post wrote, the most recent stable release of ViewVC is release 1.1.10.

Prerequisite :
1. How to Install Apache Httpd Web Server on Linux
2. How to Install Subversion on CentOS 5.5 Server

Steps to Install and Configure ViewVC.
1. Download ViewVC stable release 1.1.10
You can download using wget command on CentOS server as below:

[root@server ~]# cd /tmp
[root@server tmp]# wget
--2011-04-03 19:09:06--
Connecting to||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 602017 (588K) [application/x-gzip]
Saving to: `viewvc-1.1.10.tar.gz'

100%[===========================================>] 602,017     20.0K/s   in 29s

2011-04-03 19:09:38 (20.3 KB/s) - `viewvc-1.1.10.tar.gz' saved [602017/602017]

2. Extract and unzip the viewvc-1.1.10.tar.gz using below command:

[root@server tmp]# tar xvfz viewvc-1.1.10.tar.gz

3. Go to viewvc-1.1.10 directory and start the installation:

[root@server tmp]# cd viewvc-1.1.10
[root@server viewvc-1.1.10]# ./viewvc-install
This is the ViewVC 1.1.10 installer.

It will allow you to choose the install path for ViewVC.  You will now
be asked some installation questions.  Defaults are given in square brackets.
Just hit [Enter] if a default is okay.

Installation path [/usr/local/viewvc-1.1.10]:

DESTDIR path (generally only used by package maintainers) []:
ViewVC file installation complete.

Consult the INSTALL document for detailed information on completing the
installation and configuration of ViewVC on your system.  Here's a brief
overview of the remaining steps:

  1) Edit the /usr/local/viewvc-1.1.10/viewvc.conf file.

  2) Either configure an existing web server to run

     Or, copy /usr/local/viewvc-1.1.10/bin/cgi/viewvc.cgi to an
     already-configured cgi-bin directory.

     Or, use the standalone server provided by this distribution at

3. Edit /viewvc.conf for your specific
configuration. In particular, examine the following configuration options:

   svn_roots (for Subversion)
      root_parents (for CVS or Subversion)
[root@server ~]# vi /usr/local/viewvc-1.1.10/viewvc.conf
   147 ## Example:
    148 ## root_parents = /opt/svn: svn,
    149 ##                /opt/cvs: cvs
    150 ##
    151 root_parents =

Uncomment line 151 and define the subversion root repositories.

root_parents = /svn/repos: svn,

4. Locate your Apache configuration file. Typical locations are:

/etc/httpd/conf/httpd.conf, and

Depending on how Apache was installed. Configure Apache to expose ViewVC to users at the URL of your choice. Edit the apache web server config file as below:

[root@server ~]# vi /etc/httpd/conf/httpd.conf
565 ScriptAlias /viewvc /usr/local/viewvc-1.1.10/bin/cgi/viewvc.cgi
566 ScriptAlias /query /usr/local/viewvc-1.1.10/bin/cgi/query.cgi

or if without line number, it will be as below:

ScriptAlias /viewvc /usr/local/viewvc-1.1.10/bin/cgi/viewvc.cgi
ScriptAlias /query /usr/local/viewvc-1.1.10/bin/cgi/query.cgi
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
ScriptAlias /viewvc /usr/local/viewvc-1.1.10/bin/cgi/viewvc.cgi
ScriptAlias /query /usr/local/viewvc-1.1.10/bin/cgi/query.cgi
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.

5. Save the httpd.conf then restart the apache server.
6. Test your http://servername/viewvc. If everything properly configured, you should see the page that lists your repositories.