如何在命名虚拟主机的根目录中启用mod_dav_svn?

时间:2008-11-05 09:26:57

标签: svn apache

这可能吗?我遇到了SVN客户端无法访问存储库的麻烦,并出现以下错误消息:

  

存储库永久移动到“http://svn.example.com/test/”;请重新安置

如果我将'/'添加到我尝试访问的路径的末尾,它只是将其再次剥离,并显示相同的错误消息。我的配置文件如下:

<VirtualHost *>
  ServerName svn.example.com
  # Normal VirtualHost stuff here

  <Location /svn>
    # Uncomment this to enable the repository
    DAV svn
    SVNParentPath /some/path/to/repositories

    # Setup mod_authz_svn, etc, etc here
  </Location>
</VirtualHost>

注意:这有效。但是,如果我将位置更改为/,则会因上述错误再次停止工作。是否可以使用根目录,或者我在这里遗漏了什么?当从根目录提供存储库时,Firefox会显示存储库列表。

正如其他人所指出的那样,这似乎只是一个名为虚拟主机的问题......任何人都有任何聪明的想法为什么?

8 个答案:

答案 0 :(得分:6)

问题是你使用文档根目录作为存储库根目录(我不是在责怪你,这应该可行,但事实并非如此)。

尝试将DocumentRootSVNParentPath指令指向不同的物理位置,因此生成的配置文件应如下所示(缩写):

<VirtualHost *:80>
    DocumentRoot /home/svn.example.com/docroot

    <Location />
        SVNParentPath /home/svn.example.com/svnroot
        SVNListParentPath on
    </Location>
</VirtualHost>

另外,正如@Nigel Jewell所说,删除那个重写块,以获得理智。

答案 1 :(得分:2)

继续评论到我之前的回答,我也试过VirtualHost:

<VirtualHost 127.0.0.1:80>
<Location />
    DAV svn
    SVNPath /repository
    AuthType Basic
    AuthName "Repository authentication"
    AuthUserFile /repository/.svn-auth
    AuthzSVNAccessFile /repository/.svn-access
    Satisfy All
    Require valid-user
</Location>
</VirtualHost>

并且它正常工作,我可以使用firefox浏览存储库,并可以使用svn命令行客户端访问它。

答案 2 :(得分:2)

在/etc/apache2/conf.d/subversion.conf中找到它(需要将错误文档映射到默认值):

<VirtualHost *>
    ServerName svn.example.com
    ErrorLog    /var/log/apache2/svn.example.com-error_log
    TransferLog /var/log/apache2/svn.example.com-access_log
    #
    # Do not set DocumentRoot. It is not needed here and just causes trouble.
    #
    # Map the error documents back to their defaults.
    # Otherwise mod_dav_svn tries to find a "error" repository.
    #
    ErrorDocument 400 default
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 405 default
    ErrorDocument 408 default
    ErrorDocument 410 default
    ErrorDocument 411 default
    ErrorDocument 412 default
    ErrorDocument 413 default
    ErrorDocument 414 default
    ErrorDocument 415 default
    ErrorDocument 500 default
    ErrorDocument 501 default
    ErrorDocument 502 default
    ErrorDocument 503 default
    #
    <Location />
...
    </Location>

完成此操作后,一切都按预期开始工作。

答案 3 :(得分:1)

我最终成功地使用mod_rewrite将对根目录的所有访问权重写为/svn,从而可以从/repository_name访问存储库。作为参考,这是我最终得到的配置:

# Rewrite / into /svn to avoid errors that seem to occur when using the root
# for repositories.
RewriteEngine On
# Subdirectories that SHOULD be accessed directly, ie. trac
# /svn should be here to avoid redirect loops
RewriteCond %{REQUEST_URI} !^/(trac|svn)/
RewriteRule ^/(.*)$ /svn/$1 [PT]

答案 4 :(得分:1)

好的,我认为我们找到了应该责怪的人:命名虚拟主机:)

使用此配置:

<VirtualHost dave.test>
<Location />
    DAV svn
    SVNPath /repository
    AuthType Basic
    AuthName "Repository authentication"
    AuthUserFile /repository/.svn-auth
    AuthzSVNAccessFile /repository/.svn-access
    Satisfy All
    Require valid-user
</Location>
</VirtualHost>

当我运行命令svn ls http://dave.test时出现此错误:

svn: Server sent unexpected return value (405 Method Not Allowed) in response to
PROPFIND request for '/'

显然当尝试在命名虚拟主机的根目录中启用mod_dav_svn时会出现问题...

答案 5 :(得分:0)

This is working for me:

<Location />
    DAV svn
    SVNPath /repository
    AuthType Basic
    AuthName "Repository authentication"
    AuthUserFile /repository/.svn-auth
    AuthzSVNAccessFile /repository/.svn-access
    Satisfy All
    Require valid-user
</Location>

将浏览器指向http://127.0.0.1会向我显示存储库内容。

答案 6 :(得分:0)

由于您的意见,最后让它与VirtualHost合作。

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    ServerName svn.example.com
    ServerAlias svn
    DocumentRoot /home/svn.example.com/public_html

    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/svn$
    RewriteRule .* /svn/ [PT]

    RewriteCond %{REQUEST_URI} !^/svn/
    RewriteRule ^/(.*)$ /svn/$1 [PT]

    <Location /svn>
            DAV svn
            SVNParentPath /home/svn.example.com/public_html
            SVNListParentPath on
    </Location>

    <LocationMatch /svn/.+>
            AuthzSVNAccessFile /home/svn.example.com/support/access.cfg

            AuthType Basic
            AuthName "Subversion"
            AuthUserFile /home/svn.example.com/.htpasswd
            Require valid-user
    </LocationMatch>
</VirtualHost>

如图所示,我发现您可能还想添加:

RewriteCond %{REQUEST_URI} ^/svn$
RewriteRule .* /svn/ [PT]

为了捕捉http://svn.example.com/svn而没有结尾/.

的NiGe。

答案 7 :(得分:0)

    DocumentRoot“/ usr / local / apache / htdocs / ForSvn”     ServerName xxx.xxx     ServerAdmin xxx     ErrorLog“/ usr / local / apache / logs / xxx-error_log”     TransferLog“/ usr / local / apache / logs / xxx-access_log”

ReWriteEngine On
RewriteCond %{REQUEST_URI} ^/svn$
RewriteRule .* /svn/ [PT]

<Location /svn>
       DAV svn
       SVNParentPath /svn/repos
       SVNListParentPath on

       # Limit write permission to list of valid users.
       <LimitExcept GET PROPFIND OPTIONS REPORT>
             AuthType Basic
             AuthName "Subversion"
             AuthUserFile /svn/authfiles/svn-htpasswd
             AuthzSVNAccessFile /svn/authfiles/svn-access.conf
             Require valid-user
       </LimitExcept>
</Location>

<LocationMatch /svn/myProject/>
             AuthType Basic
             AuthName "Subversion (private)"
             AuthUserFile /svn/authfiles/svn-htpasswd
             AuthzSVNAccessFile /svn/authfiles/svn-access.conf
             Require user user1 user2 user3...
</LocationMatch>

和我一起工作。谢谢你。