【问题标题】:Access to /svn is forbidden禁止访问 /svn
【发布时间】:2013-11-05 08:51:16
【问题描述】:

我使用教程 How to set up a Subversion (SVN) server on GNU/Linux - Ubuntu 在 Ubuntu 上设置了 SVN,但是当我尝试使用 CMD 从其他机器访问存储库时,它说 禁止访问 /SVN .

我更改了文件夹的权限,并尝试了其他方法来解决问题,例如 Apache 服务器的配置,但这并没有解决我的问题。

我该如何解决这个问题?

【问题讨论】:

    标签: apache svn


    【解决方案1】:

    Apache 可以读取和写入存储库,但它的用户 (www-data) 需要获得它的所有权:

    sudo chown -R www-data:www-data /var/svn/repositories/your_repo
    

    为了能够对访问存储库的用户进行身份验证,需要密码文件:

    sudo htpasswd -c /etc/subversion/passwd your_user_name
    

    输入用户your_user_name 的密码。对于其他用户,请重复不带 -c 选项的命令,以确保现有文件被追加而不是被替换。

    然后编辑Apache配置文件:

    sudo gedit /etc/apache2/apache2.conf
    

    将以下内容添加到文件末尾:

    #svn users
    <Location /svn>
         DAV svn
         SVNParentPath /var/svn/repositories/
         SVNListParentPath On
         AuthType Basic
         AuthName "Test"
         AuthUserFile /etc/subversion/passwd
         <LimitExcept GET PROPFIND OPTIONS REPORT>
            Require valid-user
         </LimitExcept>
      </Location>
    

    保存配置文件并重启Apache:

    sudo /etc/init.d/apache2 restart
    

    现在可以通过以下方式访问测试存储库:

    http://localhost/svn/your_repo
    

    【讨论】:

      【解决方案2】:

      确保您为 Apache 设置了这样的虚拟主机:

      <VirtualHost *:80>
          DocumentRoot /home/svn/html
          ServerName svn.domainname
          ErrorLog logs/svn.domain.com-error_log
          CustomLog logs/svn.domain.com-access_log common
      
          <Directory "/home/svn/html">
              Order allow,deny
              Allow from all
              AllowOverride all
          </Directory>
      
          <Location /repos>
              DAV svn
              SVNParentPath /home/svn/repos
      
              Require valid-user
              SVNListParentPath on
              AuthType Basic
              AuthName "Your Super SVN"
              AuthUserFile /home/svn/svn-passwords-file-to-be-used-only-when-AuthType-is-used
              AuthzSVNAccessFile /home/svn/svn-repos-acl-file-but-optional
          </Location>
      </VirtualHost>
      

      并确保 Apache 可以访问 SVNParentPath 中提到的 repos 文件夹。这个问题主要是因为权限。请尝试chmod -R 0777 repos-folder,然后重试。

      【讨论】:

      • 我必须在apache中给这个site-enabled
      • 这是一个虚拟主机配置。阅读How to add a virtual host in apache。然后你就会明白了。
      • 其实我想在ubuntu中问这个。我知道如何在 apache 中添加虚拟主机,但那是在 windows 中,我想询问 linux 环境。因为我们在 ubuntu 中有不同的配置文件......
      • 如果你想在ubuntu中做,配置文件的文件一般是:/etc/http/conf/httpd.conf。在查看之前,请在 /etc/httpd/conf.d 下查找 subversion.conf 。如果该文件存在,它必须自动加载这些文件。所以相应地编辑。
      【解决方案3】:

      如果某人正在对以前有效的设置进行故障排除,这可能会对他们有所帮助。今天我们公司的新人无意中在 AuthzSVNAccessFile 使用的文件中引入了一个错字,这导致我们所有人都经历了可怕的 E175013

      【讨论】: