【问题标题】:mercurial + Apache gives 403 errormercurial + Apache 给出 403 错误
【发布时间】:2010-10-17 11:40:33
【问题描述】:

我已经在 /home/adil/hg/sample-repo 设置了我的 repo,并希望通过 httpd 提供它。我正在关注https://www.mercurial-scm.org/wiki/PublishingRepositories#multiple 的教程并创建了 hgweb.config 文件并将 hgweb.cgi(重命名为 index.cgi)复制到 /home/adil/web/mercurial/

我的 apache 配置(/etc/httpd/conf/httpd.conf)如下所示:

ScriptAlias /hg "/home/adil/web/mercurial/index.cgi"

<Directory "/home/adil/web/mercurial">
    Order allow,deny
    Allow from all
    AllowOverride All
    Options ExecCGI
    AddHandler cgi-script .cgi
</Directory>

index.cgi、hgweb.config 和所有向上的目录都具有全局读取权限

http://localhost/hg 给出“403 Forbidden”错误。怎么回事?

PS:Apache 错误日志显示: [Sun Oct 17 06:45:38 2010] [error] [client 1.2.3.4] (13)Permission denied: access to /hg denied

【问题讨论】:

  • error.log 文件说明了什么?它可能包含有关拒绝访问原因的更详细信息
  • 我用错误消息更新了我的问题。如上所述,只是权限被拒绝。它没有提供更多信息。
  • 我会用更多方法来更新答案来检查 Apache 的用户。

标签: apache mercurial http-status-code-403 hgweb


【解决方案1】:

无论如何,我都不是 Apache 配置专家,但我遇到了这个错误并设法摆脱了它。

在此之前,我的 error_log 中出现了这个错误:client denied by server configuration: /Users/svn/Public/hg/hgwebdir.cgi

这是我原来的配置:

ScriptAlias /hg "/Users/svn/Public/hg/hgwebdir.cgi"
<Location /hg>
   AuthType Basic
   AuthName "Mercurial Repositories"
   AuthUserFile /Users/svn/Public/hg/auth
   Require valid-user
</Location>

我添加了一些选项:

ScriptAlias /hg "/Users/svn/Public/hg/hgwebdir.cgi"
<Location /hg>
  Options ExecCGI FollowSymLinks
  Options None
  Order allow,deny
  Allow from all

  AuthType Basic
  AuthName "Mercurial Repositories"
  AuthUserFile /Users/svn/Public/hg/auth
  Require valid-user
</Location>

我也尝试了 Pablo 的版本 - 我遇到的一个问题是“ScriptAliasMatch ^/hg(.*)”正在捕获渲染浏览器 repo 浏览器所需的 hg 徽标和样式表。我不确定这是否适用于hgweb.cgi,因为我不使用那个,但在使用hgwebdir.cgi 时这绝对是一个问题。具体:script not found or unable to stat: /Users/svn/Public/hg/hgweb.cgilogo.png

【讨论】:

    【解决方案2】:

    可能 Apache 的进程所有者没有访问 /home/adil/web/mercurial 的权限。

    另外,请检查 Apache 的错误日志(通常位于 /var/log/httpd-error.log 或类似的地方。它会为您提供额外的信息来调试您的安装。

    要检查运行 Apache 进程的用户做什么:

    $ ps aux | grep http
    

    ps 应该显示正在运行 Apache 的用户。

    另外,如果有帮助,我会这样做:

    ScriptAliasMatch        ^/hg(.*)        /usr/local/share/mercurial/www/hgweb.cgi$1
    <Directory /usr/local/share/mercurial/www>
      Options ExecCGI FollowSymLinks
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
    </Directory>
    

    【讨论】:

    • Pablo,它对所有目录都有读取权限。如何检查用户 'apache' 是否可以访问它?
    • 它是否也具有存储库的权限?还是仅用于 CGI 脚本?
    猜你喜欢
    • 2013-08-29
    • 2011-04-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-01
    • 2018-10-17
    • 2014-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多