如何设置 Apache 以通过此特定 URL 配置为 SVN 提供服务?
我有一个 VPS,并且正在尝试托管多个 SVN 项目。 我希望 URL 路径如下所示:
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
但是,使用下面的代码,第一件事(欢迎 HTML 页面)不会显示,因为 Location 块优先于 DocumentRoot。
将位置块设置为
有效,但随后我的 URL 变为 http://svn.domain.com/repos/project1
,但我不这样做喜欢。
有什么建议么?
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 SVNPATH 指令,但是您必须设置三个位置(每个项目都需要自己的位置)
you can use SVNPATH directive, however you have to set up three locations (each project needs its own)
您可以通过为 SVN 存储库添加子域来解决此问题,而无需每次添加新项目时都更改 Apache 配置。 你最终会得到这样的结果:
然后你必须使用 http://svn.domain.com/svn/project1/,但是如果你想添加project4等,你所要做的就是在/var/svn下添加新的存储库。
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:
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.
mod_rewrite 怎么样? 您可以为非 SVN 内容设置一个文件夹 (http://example.com/info/) ,然后使用 mod_rewrite 将 '/' 或 '/index.php' 的请求重定向到 '/info/index.php'。 那行得通吗?
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?