【问题标题】:Mercurial and hgweb on IIS 7.5 - python errorIIS 7.5 上的 Mercurial 和 hgweb - python 错误
【发布时间】:2011-05-20 07:23:33
【问题描述】:

我正在尝试让 Mercurial 托管在 IIS 7.5(Win 7 x64)上,但一直遇到我似乎无法修复的错误。

我在这里学习了 Jeremy Skinners 的教程:Mercurial on IIS7

我使用的是 hgweb,而不是 hgwebdir,因为我使用的是 Mercurial 1.7.2

我已经安装并运行了 python。我在目录 c:\inetpub\wwwroot\hg 中的 http://localhost/hg -> 为 Mercurial 设置了一个 IIS 应用程序

我将模板目录放入 c:\inetpub\wwwroot\hg 我将 library.zip 文件解压缩到 c:\inetpub\wwwroot\hg

当我访问该站点时,我收到一个错误 -> 文件“C:\inetpub\wwwroot\hg\hgweb.cgi”,第 15 行,in from mercurial import demandimport; demandimport.enable() ImportError: No module named mercurial ".

在搜索这个错误时,我找到了以下答案:https://stackoverflow.com/questions/2123798/

根据接受的答案,我将 hgweb.cgi 更改为如下所示:

#!c:/python/python26/python.exe
#
# An example hgweb CGI script, edit as necessary
# See also https://www.mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/path/to/repo/or/config"

# Uncomment and adjust if Mercurial is not installed system-wide:
import sys; sys.path.insert(0, "c:\inetpub\wwwroot\hg")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb('c:\inetpub\wwwroot\hg\hgweb.config')
wsgicgi.launch(application)

这样做之后,我仍然得到同样的错误。我不知道还能做什么。任何帮助将不胜感激。

Edi 1:c:\inetpub\wwwroot\hg 的屏幕截图(根据请求):

【问题讨论】:

  • 你能张贴 c:\inetpub\wwwroot\hg 内容的截图或其他内容吗?也许这些文件最终位于它们应有的子目录中。
  • @Lasse 根据您的要求发布了屏幕截图。
  • 我遇到了同样的错误并研究了解决方案然后创建了comprehensive instructions to setup mercurial hgweb on iis7
  • 我知道这篇文章很旧,但你的链接现在在 403 后面 @Firegarden

标签: python iis mercurial hgweb


【解决方案1】:

在过去一周左右的时间里,我一直在为同样的设置而苦苦挣扎。

在我看来,他们最近对 IIS 中的 mercurial 工作方式进行了一些重大更改,因此上面指向 Jeremy Skinners 教程的链接对于 1.7.2 将存在问题

这是more recent link 我发现我必须做一些不同的事情。

这些说明适用于 1.7.x,如果您使用的是 1.8.x,请务必阅读下方 Ethan 的评论!

我按照the comments of /contrib/win32/hgwebdir_wsgi.py中的说明进行操作。

  • 安装Python 2.6.6

  • 将 Python 添加到系统 PATH(以使 生活更轻松)

  • 安装pywin32 v214(使用 Python 安装程序,重要!)(注意 这是针对python构建的 2.6)

  • 安装isapi_wsgi

  • download the mercurial source package
    提取,然后运行

    python setup.py --pure build_py -c -d 。 build_ext -i build_mo --force python setup.py --pure install --force
  • 将 hgwebdir_wsgi.py 从 /contrib/win32 复制到您要从中托管它的文件夹。

  • 在您要托管的文件夹中创建一个文件 hgweb.config。添加内容

    [路径] yourRepoName = c:\yourRepoLocation
  • 编辑 hgwebdir_wsgi.py 以指向 hgweb.config。如果 hg,path_prefix 为 0 是网站的根。如果 你把它放在 vdir 1 深的地方, 然后是 1,等等。

  • 运行 python hgwebdir_wsgi.py 创建 isapi dll _hgwebdir_wsgi.dll。 控制台应该打印出来 “安装完成”

  • 在 IIS 中创建应用程序池(否 托管代码)

  • 使用文件夹创建您的网站 设置为相同的文件夹 hgwebdir_wsgi.py

  • 添加模块类型的处理程序,使用“*” 作为映射,选择 _hgwebdir_wsgi.dll 作为可执行文件,选择 isapimodule 作为类型, Mercurial-ISAPI 作为名称(虽然 名字并不重要)

  • 编辑功能权限 允许执行的模块。

web.config(前两步):

<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<add name="Mercurial-Isapi" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\inetpub\hgweb\_hgwebdir_wsgi.dll" resourceType="Unspecified" />
</handlers>
</system.webServer>

在这一切之后,我能够让它工作。

最后一件事,我确实将 MFC71.dll 复制到 windows/system32,虽然我不确定是否有必要 http://python.net/crew/skippy/win32/

我认为我在这里得到的和上面的链接之间的主要区别是我做了“纯 python”mercurial 安装,虽然我是一个完整的 python 新手,所以我不确定。我还为 pywin 和 isapi_wsgi 做了“python 安装”,而不是普通的 windows msis。

【讨论】:

  • 在我执行此步骤之前一切正常:运行 python hgwebdir_wsgy.py 以创建 isapi dll _hgwebdir_wsgy.dll。控制台应该打印出“安装完成”我收到以下错误: Traceback (last recent call last): File "hgwebdir_wsgi.py", line 61, in import isapi_wsgi ImportError: No module named isapi_wsgi
  • 我确实花了 6 个小时试图找到一组有效的指令。为什么我必须最后找到这个?干得好!
  • 仅供参考——从 1.8 开始,mercurial.selenic.com/wiki/WindowsInstall 中描述的“纯”版本不再适用于我。我必须安装 MinGw,将 c:\mingw\bin 添加到系统路径,然后使用 [build]compiler=mingw32 创建文件 C:\Python26\Lib\distutils\distutils.cfg 之后,您可以执行 'easy_install ctypes' 从 1.8 开始使用 ctypes 而不是 PyWin32 来进行 Win32 api 调用。然后,您可以遵循上面 mercurial 链接中概述的“标准”程序,而不是“纯”变体。
  • 我已经写出了current instructions here
  • 我按照这些说明使用 Mercurial 2.0.1 并使用 MinGW 5.1.6,如 Ethan 上面 3 月 2 日的评论中所述。
【解决方案2】:

我之前确实有很多错误。 卸载所有 python、pywin32、isapi_wsgi 并像上面一样安装它。 它轻而易举。 卢克

【讨论】:

    【解决方案3】:

    Adam Boddington 编写了更新的安装说明,现在可以使用:http://stackingcode.com/blog/2011/02/24/running-a-mercurial-server-on-iis-7-5-windows-server-2008-r2

    【讨论】:

      【解决方案4】:

      我使用当前版本的 Mercurial (1.8.x) 和当前版本的 Python (2.7) 写出了 up to date instructions on how to setup a mercurial repository on IIS7

      这对你有用,如果你用它来投票赞成(或反对)答案,我将不胜感激。

      【讨论】:

      • 最后是一个适用于 64 位 windows server 2008、IIS 7、Python 2.7 和 Mercurial 1.7.2+ 的教程。谢谢!
      猜你喜欢
      • 2010-10-23
      • 1970-01-01
      • 2011-04-11
      • 1970-01-01
      • 2015-02-02
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      相关资源
      最近更新 更多