WebSVN Installation Guide

Content

Why WebSVN?

WebSVN offers a view of your subversion repositories that's been designed to reflect the Subversion methodology. You can view the log of any file or directory and see a list of all the files changed, added or deleted in any given revision. You can also view the differences between versions of a file to see exactly what was changed in a particular revision.

WebSVN offers the following key features:

Since it's written using PHP, WebSVN is also very portable and easy to install.

Installation

Grab the source and stick it somewhere that your server can get to. You need to have PHP 5.6 or greater installed and working. Additionally you need SVN 1.7 or greater. Also note that WebSVN won't currently work in safe mode, due to the need to call the svn and svnlook commands. While no other external programs are required, you need to provide additional PHP libraries if not already installed. It's recommended to use the package manager of your OS-distribution for each individual library or, if it doesn't provide those, that of PHP itself called PEAR. At least PEAR should most likely be available using the package manager of your OS-distribution. With e.g. a Debian based Linux simply issue the following commands to install the dependencies using PEAR:

  1. apt-get install php-pear
  2. pear channel-discover pear.geshi.org
  3. pear install Archive_Tar
  4. pear install geshi/geshi
  5. pear install Text_Diff

If it isn't already, make sure the cache directory has permissions of at least 0700 and is owned by the process your webserver is running under. This is used to cache RSS files. It is not recommended to set the directory to full write, 0777.

Make a copy of include/distconfig.php and name it include/config.php, then edit it as directed in the file itself. Even with only the default config file, pointing your browser at the index.php file should display a WebSVN page that instructs you to set up one or more repositories.

Adding Repositories

Repositories to be browsed must be specified in include/config.php so WebSVN knows how to access them. The two simplest ways to specify repositories are to use:

Credentials

If WebSVN must supply a username and password to access a remote repository, you can supply these arguments in the $config->addRepository(...) call for that repository — consult include/distconfig.php for specifics. If the credentials are sensitive, be sure to set the read permissions for the config file appropriately.

Groups

WebSVN allows you to group repositories logically if desired — include/distconfig.php documents how to associate repositories and parent paths with groups in detail. When groups exist, using $config->useTreeIndex() will create a hierarchical index page with collapsible/expandable group sections.

SVN Client URLs

If you want to provide the URL that SVN clients should use to access a repository (whether local or remote), you can provide it for a single repository or a parent path — consult include/distconfig.php for specifics. The SVN client link should be to the root path of a repository; path elements will be appended to it as needed. To see this in action, browse demo.websvn.info and look for the SVN links.

Templates

WebSVN is able to customize its appearance through the use of a templating system, and includes several built-in templates. The template paths users can choose from may be specified in include/config.php using $config->addTemplatePath(...) etc.

Those who wish to customise the look and feel a little should read templates.html, which explains the highly configurable template system.

Colourisation

GeSHi (Generic Syntax Highlighter) is bundled with WebSVN. To use it, just make sure config.php has this line uncommented:

$config->useGeshi();

Alternatively, you can use Enscript 1.6 or higher to view files with syntax colouring. (You'll also need sed.) To use Enscript, simply set the paths in the config file, comment out the GeSHi line above, and then uncomment this line:

$config->useEnscript();

Multiviews

You may choose to configure access to your repository via Apache's MultiView system. This will enable you to access a repository using a url such as:

http://example.com/browse/repname/path/in/repository

To do this you must:

Now go to http://example.com/browse/ and make sure that you get the index page.

The repname part of the URL is the name given to it in the config.php file. For this reason you may wish to avoid putting spaces in the name.

Multiviews example

First, Apache needs to know that you want to enable MultiViews for the root directory. You may need to enable the MultiViews option in the Apache configuration, as explained in these Apache docs. For example, if my Apache directory root were set /var/apache/htdocs, the corresponding block in Apache might look something like this:

<Directory "/var/apache/htdocs">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Alternatively, you can include the following line in the directory's .htaccess file, assuming that the appropriate AllowOverrides directive is set up.

Options MultiViews

Let's suppose that WebSVN is installed in a directory called websvn within the Apache document root directory. Normally, WebSVN would be accessed at http://example.com/websvn/. With MultiViews enabled, the base path for all WebSVN pages would be http://example.com/websvn/browse/. (If you would prefer http://example.com/browse/ instead, move/copy browse.php from the WebSVN installation to the document root directory.) You may need to modify the $locwebsvnhttp variable at the beginning of browse.pnp to match your directory location.

You must also enable Multiviews in the WebSVN include/config.php file by adding this line:

$config->useMultiViews();

If all has gone well, repositories should now by accessible at http://example.com/browse/.

Note the index page can be accessed through http://example.com/browse/. If you want to view the index page at http://example.com/, you need to add another directive to the .htaccess file:

DirectoryIndex browse.php

Access rights and authentication

You may wish to provide an authentication mechanism for WebSVN. One obvious solution is to protect the entire WebSVN directory with some form of Apache authentication mechanism, but that doesn't allow for per repository authentication.

WebSVN provides and access rights mechanism that uses your SVN access file to control read access to the repository. This means that you only have to maintain one file to define both Subversion and WebSVN access rights.

For this to work, you need to configure your authentication method to the /websvn/ (or /wsvn/) directory. This should be the same authentication as you use for the svn repositories themselves.

Note the use of the trailing / in the Location directive. If you use <Location /websvn>, you won't be able to access the index.

You should change /websvn/ to /browse/ if you're using multiviews.

Also note that you should not use the AuthzSVNAccessFile command to define the access file.

Now that you've defined your authentication, you'll be asked for your user name and password in order to access the WebSVN directory. All that's left is to configure WebSVN to use your Subversion access file to control access. Add this line to your config.php file:

$config->useAccessFile('/path/to/accessfile');

Note that if your access file gives read access to, for example, path /a/b/c/ but not to /a/b/, then the user will be given restricted access to /a/b/ in order to reach /a/b/c/. The user will not be able to see any other files or directories in /a or /a/b/.

You should read the Subversion book for information on the access file format.

Common problems

Accented Characters
WebSVN is designed to worked with accented characters. To do this, it uses either the multibyte string funtions or the iconv function. This may not be installed on your system. If you aren't getting the characters that you expect, make sure that the multibyte string or iconv extension is being loaded in php.ini. Windows users will need to copy the appropriate DLLs of iconv to the system directory (from the PHP installation directory).
Executing a Windows shell
On a Windows machine, this error is reported: Warning: shell_exec(): Unable to execute. If you experience this problem, you need to give IUSR_<machinename> execute permissions on <systemroot>\system32\cmd.exe. Under most systems, the file will be C:\WINDOWS\system32\cmd.exe. Right-click on the file, choose properties, and on the security tab click the "Add" button. Add the IUSR_<machinename> user, and then select the "read" and "read & execute" boxes.

License

GNU Public licence