如何设置 Apache 以通过此特定 URL 配置为 SVN 提供服务?

发布于 2024-07-16 20:50:07 字数 1387 浏览 8 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜扑 2024-07-23 20:50:07

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

you can use SVNPATH directive, however you have to set up three locations (each project needs its own)

情何以堪。 2024-07-23 20:50:07

您可以通过为 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/,但是如果你想添加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:

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

二智少女猫性小仙女 2024-07-23 20:50:07

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文