【问题标题】:How can I setup Apache to serve SVN with this particular URL configuration?如何设置 Apache 以使用此特定 URL 配置服务 SVN?
【发布时间】:2010-10-16 03:20:08
【问题描述】:

我有一个 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。

将 Location 块设置为 <Location /repos> 有效,但是我的 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>

【问题讨论】:

    标签: svn apache path httpd.conf


    【解决方案1】:

    mod_rewrite 呢?您可以为非 SVN 内容设置一个文件夹 (http://example.com/info/),然后使用 mod_rewrite 将“/”或“/index.php”的请求重定向到“/info/index.php”。这行得通吗?

    【讨论】:

    • 我相信我尝试了这个解决方案,但它失败了。我不知道确切原因,我很确定它只是不起作用(tm)。明天我会再试一试,然后回来报告。
    • 使用 DAV 下的位置是行不通的,因为一旦启用,您就无法在子位置中禁用 DAV。但是使用 mod rewrite 重定向到另一个域可以工作RewriteRule ^/info/(.*)$ http://someotherhost/info/$1 [R]。
    【解决方案2】:

    您可以通过为 SVN 存储库添加子域来解决此问题,而无需在每次添加新项目时更改 Apache 配置。你最终会得到这样的结果:

    <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>
    

    然后您必须使用http://svn.domain.com/svn/project1/ 形式的 URL 访问您的存储库,但如果您想添加 project4 等,您只需在 /var/svn 下添加新的存储库。

    【讨论】:

    • 您的意思是“子目录”,而不是子域,这是真的,但这是我试图避免的:)。不过还是谢谢。
    【解决方案3】:

    您可以使用 SVNPATH 指令,但是您必须设置三个位置(每个项目都需要自己的)

    【讨论】:

    • 我希望我不必这样做,而且我只是缺乏我的 Apache 配置知道如何:-/
    猜你喜欢
    • 2016-08-06
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多