Section 3.4. Configuring SVN to Use Apache


3.4. Configuring SVN to Use Apache

If you plan to use the Subversion WebDAV extensions for remote access to your repository, you have to set up Apache to load the SVN WebDAV module and tell it where to find your repository. Also, make sure that Apache has read/write access to any repositories that you want it to serve.

3.4.1. Loading the Modules

The first step is to make sure that Apache is set up to load the mod_dav and mod_dav_svn modules (mod_dav is not compiled in Apache by default so you may have to compile it yourself; most distributions of Apache do have it compiled already though). Subversion's make install command should have done this for you, but it's a good idea to take a quick look to make sure everything seems correct. The LoadModule directive for the SVN DAV module should be in your httpd.conf file. The location of the httpd.conf file is very system specific, and depends a lot on how Apache was installed on your particular system. In general, though, you will probably find it either in /usr/local/apache2/conf or somewhere under the /etc directory on most UNIX-based systems. If you are installing under Windows, the httpd.conf file should be in the directory where Apache is installed (which is probably C:\Program Files\Apache Group\Apache2\conf). If you have both Apache 1 and Apache 2 installed on your system, make sure that the httpd.conf file you are checking is the configuration file for Apache 2.

After you have found the httpd.conf file, you should check it for the LoadModule directives for mod_dav_svn and mod_dav, which should look something like this:

LoadModule

dav_module

modules/mod_dav.so

LoadModule

dav_svn_module

modules/mod_dav_svn.so


There may be other LoadModule directives between mod_dav and mod_dav_svn, but it is important to make sure that mod_dav is loaded before mod_dav_svn. On some systems, mod_dav may have been statically compiled into Apache, in which case there is no need to have a LoadModule directive for it.

3.4.2. Setting Up Access

In order to allow people to access your repository through Apache, you need to set up a Location directive to tell Apache where to find the repository, as well as what URL path to use. The Location directive will also go in your httpd.conf file, and should be added to the end of the file, to ensure that everything has been loaded properly before it is processed.

A basic Location directive for your repository will look something like this:

 <Location /repos>     DAV svn     SVNPath /srv/subversion/repos     AuthType Basic     AuthName "Subversion"     AuthUserFile /srv/subversion/svn_passwd     Require valid-user </Location> 

Let's look at what each line in the preceding directive means.

The first line opens the Location directive. The path given after Location tells Apache what the URL path to the repository should be. For example, in the preceding sample directive, if your Web site were at www.example.com, the URL for the repository would be http://www.example.com/repos. The Location directive is then closed by the </Location> tag on the last line.

The second line of the directive tells Apache that the location you are setting up points to a WebDAV share, which should use the SVN extensions. That is followed by the third line, which tells Apache where to find the Subversion repository, which should give an absolute path to the directory that was created when svnadmin create made your repository.

The next four lines set up the security policies for the repository. AuthType Basic informs Apache that you want simple password protection, and AuthName is the name that should be used when requesting the password. The AuthUserFile gives the file that contains the valid users and their passwords. Finally, Require valid-user specifies that a valid authorization should be required for all operations on the repository. For a more detailed discussion on securing your WebDAV share, see Chapter 10, "Administrating the Repository."

Setting a Parent Path for Multiple Repositories

If you want to set up your httpd.conf file for multiple repositories, you can always add multiple Location directives to individually configure each repository; however, if you have a lot of repositories, that can be a major painespecially if repositories are frequently added or removed. To solve that problem, Subversion allows you to set up a single Location that points to a parent directory that contains one or more repositories, using the SVNParentPath directive. Apache will automatically pick up each repository in the parent directory and allow clients access.

As an example, say we have two repositories named repos_uno and repos_dos. If we place both of those repositories in the directory /srv/svnrepositories, the Location can be set up as follows.

 <Location /repos>     DAV svn     SVNParentPath /srv/svnrepositories     AuthType Basic     AuthName "Subversion"     AuthUserFile /srv/svnrepositories/svn_passwd     Require valid-user </Location> 

The two repositories would then be accessible through the URLs

http://svn.example.com/srv/svnrepositories/repos_uno

and

http://svn.example.com/srv/svnrepositories/repos_dos

respectively.

3.4.3. Using Apache 2 and Apache 1 Together

Subversion requires version 2.0 or later of the Apache Web server in order to allow Web-DAV repository access. Version 2 of Apache, however, was a major overhaul of the server, and not all of the extensions supported by Apache 1 are supported under Apache 2. This means that you may find that your server needs to support both versions of Apache for different parts of your Web site. Fortunately, Apache supports running two versions side by side, and setting Apache 1 up to point certain URLs (like the path to your repository) to a running instance of Apache 2 is relatively easy.

The first thing you need to do is to set Apache 2 up to run on a different port than the default port 80 that HTTP runs on by default. A good choice here is to use port 8080. To change Apache 2's port, you need to edit your httpd.conf file and look for a line that says Listen 80, which you will need to change to Listen 8080. If there is no Listen directive in your httpd.conf file, go ahead and add one. That's it. You can now run both versions of Apache at the same time, and both will be accessible. Apache 1 will still be accessible as normal, and Subversion can be accessed on Apache 2 by entering the port number in the URL (e.g. http://www.example.com:8080/repos).



    Subversion Version Control. Using The Subversion Version Control System in Development Projects
    Subversion Version Control. Using The Subversion Version Control System in Development Projects
    ISBN: 131855182
    EAN: N/A
    Year: 2005
    Pages: 132

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net