Linux – Where should I put the svn repository

linuxsvn

I am trying to setup a testing server for web development. I have never done this before nor have I ever used svn before.

When I go to http://linux-server/ from any computer on my network it takes me to the /var/www path my linux machine.

I am using svn to backup everything inside /var/www

currently my svn repository is located at /usr/local/svn/svn_repo

if I run:

$ svn list -v -R
file:///usr/local/svn/svn_repo

it outputs:

 11 root                  Jun 17 17:03 ./
  1 root                  May 25 14:05 branches/
  1 root                  May 25 14:05 tags/
 11 root                  Jun 17 17:03 trunk/
 11 root                  Jun 17 17:03 trunk/www/
 11 root             2525 Jun 17 17:03 trunk/www/index.php
  4 root                  May 25 16:48 trunk/www/test/
  4 root              105 May 25 16:48 trunk/www/test/index.php

Where trunk/www/ is the same as /var/www on the system.

But I want to be able to access my repository from another machine on the network. Something like http://linux-server/svn

Maybe I am thinking about this wrong but it seems to me like in order to do that, I would need to move the repository to /var/www/svn/ directory. But then wouldn't the repository be backing up itself? or is it OK as long as I never call:

svn add /var/www/svn

I am a little confused.

Best Answer

No, you're right that you shouldn't have the repository inside its own working copy. What you can do is use an Alias directive (if you're using Apache) to map the directory /usr/local/svn/svn_repo to the URL path /svn.

Alias /svn/ /usr/local/svn/svn_repo/

This way when you direct your browser to http://linux-server/svn, Apache will show you the contents of /usr/local/svn/svn_repo, but that directory won't actually be inside /var/www. You will also need to enable Apache to serve files from that directory, so put this in your Apache configuration file:

<Directory /usr/local/svn/svn_repo>
    Order allow,deny
    Allow from all
    Options +Indexes
</Directory>

Note that you should also configure Apache with WebDAV so that you can access the repository over HTTP (otherwise Apache will show you the raw contents of the repository files, which won't be particularly easy on the eyes).