【问题标题】:Hosting Mercurial with IIS 6使用 IIS 6 托管 Mercurial
【发布时间】:2010-11-14 12:53:21
【问题描述】:

我正在尝试在 Windows Server 2003 下设置由 IIS 托管的 Mercurial 存储库。在 this post 之后,我安装了 Python 2.5.4.4 和 Mercurial 1.3,设置虚拟目录,提取 library.zip 并创建 hgwebdir.config .

但是,当我尝试打开 http://hostname/hg/hgwebdir.cgi 时,我收到一个错误“指定的 CGI 应用程序因未返回完整的 HTTP 标头集而行为不端”。我尽了最大努力:

  1. 检查 IIS 到 .py 和 .cgi 扩展名的映射。我什至尝试使用 FastCGI,但没有成功。
  2. 在同一个目录中创建了“Hello World”并检查它是否正常工作。
  3. 检查了 IUSR、IWAM 和 NETWORK SERVICE 对 Python、IIS 和 repos 目录的读取/执行权限。
  4. 尝试从Mercurial mailing list 应用两个不同的补丁。由于他们都老了,我没有成功。
  5. 安装了 Sysinternals 的 procmon 并在请求期间检查文件系统错误。除了在 Python 进程中加载​​它的库时,我没有发现很多缓冲区溢出结果。
  6. 尝试在脚本中添加“Content-type: text/html”。

另一件事是,当我请求不存在的脚本文件(例如 /hg/inexist.cgi)时,我遇到了同样的错误。没有任何帮助!

【问题讨论】:

    标签: python iis-6 mercurial


    【解决方案1】:

    还有一些我需要解决的问题:

    • 各种 HOWTO 说要使用 c:\whatever\Python26\python.exe -u "%s" "%s" 而不是使用 c:\whatever\Python26\python.exe -u -O -B "%s" "%s" -O 会导致它也查找 .pyo 文件(不仅仅是 .py 或 .pyc,至少在我的版本中不存在)。 -B 使其不尝试将找到的 .py 文件编译成 .pyo 文件(由于缺少写权限而失败)
    • 我安装了 Python 2.7。 Mercurial 1.6.2 的 .pyo 文件是用 Python 2.6 编译的。这导致了一个幻数错误。卸载 2.7 并安装 2.6.5 解决了这个问题。 (如果您在将来的某个时间阅读此内容,则此内容可能不再相关 - 检查 Mercurial 目录或 TortoiseHg 目录中 DLL 的名称,具体取决于您从哪里获取 library.zip)
    • hgwebdir.cgi 现在只是 hgweb.cgi - webdir 已集成到其中

    【讨论】:

      【解决方案2】:

      最后我得到了任何 python 脚本错误返回的“no headers”错误,所以我用控制台解释器检查了脚本并修复了我的配置文件中的错误。当然,我应该在 ServerFault 而不是 StackOverflow 上问这个问题 - 睡眠不足完成了这项工作:)

      【讨论】:

      • 嘿,cgi 最终的实际问题是什么?我还在为这个而痛苦..
      • 我遇到了类似的问题。您能否发布您必须更改的内容以解决您的问题?
      • 在我的情况下,配置文件中有错误。在本地计算机“python index.py”上启动脚本并检查输出。
      【解决方案3】:

      http://vampirebasic.blogspot.com/2009/06/running-mercurial-on-windows.html 有一篇很好的文章可以帮助你入门,但如果你需要更多细节或比作者更进一步,我有一篇由 4 部分组成的博客文章,涵盖了你需要知道的所有内容关于在 IIS 上启动和运行,包括 Active Directory 集成、拉/推权限、自定义 UI:

      http://www.endswithsaurus.com/2010/05/setting-up-and-configuring-mercurial-in.html

      值得一读……

      【讨论】:

        【解决方案4】:

        在我的情况下,这个错误是由 hgweb.cgi 中的application = hgwebdir('c:\somewhere\hgweb.config') 行引起的,应该是application = hgweb('c:\somewhere\hgweb.config')。

        此外,在 hgweb.cgi 中取消注释行 import cgitb; cgitb.enable() 将为您提供有关错误(和其他错误)的更多信息。

        附:我在带有 IIS 6.0 的 Windows Server 2003 上使用 Python 2.6.6 和 Mercurial 1.7.3。

        【讨论】:

          【解决方案5】:

          就我而言,修复它的关键步骤是:c:\whatever\Python26\python.exe -u -O -B "%s" "%s

          在此之前它无法处理错误:

          A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
          
           c:\hg\hgweb.cgi in ()
             13 import cgitb; cgitb.enable()
             14 
             15 from mercurial import demandimport; demandimport.enable()
             16 from mercurial.hgweb import hgweb, wsgicgi
             17 application = hgweb(config)
          mercurial undefined, demandimport undefined
          <type 'exceptions.ImportError'>: No module named mercurial 
                args = ('No module named mercurial',) 
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-06-24
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-12-28
            相关资源
            最近更新 更多