How can I setup Apache to serve SVN with this particular URL configuration?
-
22-08-2019 - |
Question
I have a VPS and i'm trying to host several SVN projects. I'd like the URL paths to be like this:
http://svn.domain.com -> Welcome HTML page (at /var/www/svn.domain.com/httpdocs/index.php)
http://svn.domain.com/project1 -> Project 1 SVN Root
http://svn.domain.com/project2 -> Project 2 SVN Root
http://svn.domain.com/project3 -> Project 3 SVN Root
However, with the code below, The first thing (Welcome HTML page) doesn't show up, as the Location block takes precedence over the DocumentRoot.
Setting the Location block to <Location /repos>
works, but then my URLs become http://svn.domain.com/repos/project1
, which I do not like.
Any suggestions?
<VirtualHost *>
ServerName svn.domain.com
DocumentRoot /var/www/svn.domain.com/httpdocs
<Location />
DAV svn
SVNParentPath /var/svn
SVNIndexXSLT "/svnindex.xsl"
AuthzSVNAccessFile /var/svn/access
SVNListParentPath On
# try anonymous access first, resort to real
# authentication if necessary.
Satisfy Any
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/passwd
</Location>
</VirtualHost>
<Directory /var/svn>
Allow from all
</Directory>
Solution
you can use SVNPATH directive, however you have to set up three locations (each project needs its own)
OTHER TIPS
You could get around this without having to change your Apache configuration every time you add a new project by adding a subdomain for your SVN repositories. You'd end up with something like this:
<VirtualHost *>
ServerName svn.domain.com
DocumentRoot /var/www/svn.domain.com/httpdocs
<Location /svn>
DAV svn
SVNParentPath /var/svn
SVNIndexXSLT "/svnindex.xsl"
AuthzSVNAccessFile /var/svn/access
SVNListParentPath On
# try anonymous access first, resort to real
# authentication if necessary.
Satisfy Any
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/passwd
</Location>
<Directory /var/svn>
Allow from all </Directory>
<Directory /var/www/svn.domain.com/httpdocs>
# Doc. root directives here</Directory>
You'd then have to access your repositories with URLs of the form http://svn.domain.com/svn/project1/, but if you want to add project4 etc. all you have to do is add the new repository under /var/svn.
What about mod_rewrite? You could set up a folder for non-SVN stuff (http://example.com/info/), then use mod_rewrite to redirect requests for '/' or '/index.php' to '/info/index.php'. Would that work?