IIS 7.5上的Mercurial和hgweb-python

2024-05-13 04:27:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图让Mercurial托管在IIS7.5(Win7x64)上,并不断遇到一个似乎无法修复的错误。

我在这里学习了杰里米·斯金纳斯的教程:Mercurial on IIS7

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

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

我将templates目录放在c:\ inetpub\wwwroot\hg中 我将library.zip文件解压到c:\inetpub\wwwroot\hg中

当我访问该站点时,我收到一个错误->;文件“C:\inetpub\wwwroot\hg\hgweb.cgi”,第15行,来自mercurial import demandimport;demandimport.enable()import error:没有名为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根据请求的屏幕截图:My Hg directory


Tags: 文件toimportgt目录configenable错误
3条回答

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

在我看来,他们最近对mercurial在IIS中的工作方式做了一些重大的改变,因此上面到Jeremy Skinner教程的链接对于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添加到系统路径(使 生活更轻松)

  • 安装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。添加内容

    [paths]
    yourRepoName = c:\yourRepoLocation
    
  • 编辑hgwebdir_wsgi.py以指向 hgweb.config.配置。如果hg,则path_前缀为0 是网站的根目录。如果 你把它放进一个深的视频显示器里, 然后是1,等等。

  • 运行python hgwebdir_wsgi.py创建 isapi dll\u hgwebdir\u 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。

Adam Boddington已经编写了一个更新的安装描述,现在可以工作了:http://stackingcode.com/blog/2011/02/24/running-a-mercurial-server-on-iis-7-5-windows-server-2008-r2

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

这对你有用,如果你用它来给答案投赞成票(或反对票)。

相关问题 更多 >