IIS 7.5 上的 Mercurial 和 hgweb - python 错误

发布于 2024-10-05 15:40:49 字数 1725 浏览 0 评论 0原文

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

我在这里遵循了 Jeremy Skinners 教程: IIS7 上的 Mercurial

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

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

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

当我访问该站点时,出现错误 ->文件“C:\inetpub\wwwroot\hg\hgweb.cgi”,第 15 行,来自 Mercurial importdemandimport; demandimport.enable()ImportError:没有名为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 的屏幕截图:我的 Hg 目录

I am trying to get Mercurial to host on IIS 7.5 (Win 7 x64) and keep running into an error I cant seem to fix.

I have followed Jeremy Skinners tutorial here: Mercurial on IIS7

Instead of hgwebdir, I use hgweb as I am using Mercurial 1.7.2

I have python installed and working. I set up a IIS application for Mercurial at http://localhost/hg -> in directory c:\inetpub\wwwroot\hg

I placed the templates directory into c:\inetpub\wwwroot\hg
I extracted the library.zip file into c:\inetpub\wwwroot\hg

When I visited the site, I get an error -> File "C:\inetpub\wwwroot\hg\hgweb.cgi", line 15, in from mercurial import demandimport; demandimport.enable() ImportError: No module named mercurial ".

When searching for this error, I found the following answers: https://stackoverflow.com/questions/2123798/

Following the accepted answer, I changed my hgweb.cgi to look like this:

#!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)

After doing that, I still get the same error. I have no idea what else to do. Any help would be greatly appreciated.

Edi 1: Screen shot of c:\inetpub\wwwroot\hg as per request: My Hg directory

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

肤浅与狂妄 2024-10-12 15:40:49

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

在我看来,他们最近对 Mercurial 在 IIS 中的工作方式做了一些重大更改,因此上面的 Jeremy Skinners 教程链接对于 1.7.2 会有问题

。 net/blog/post/2010/04/08/Setting-up-Mercurial-server-in-IIS7-using-a-ISAPI-module.aspx" rel="nofollow noreferrer">更新的链接
我发现我必须做一些不同的事情。

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

我按照 /contrib/win32/hgwebdir_wsgi.py 的注释。

  • 安装Python 2.6.6

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

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

  • 安装isapi_wsgi

  • 下载mercurial源码包
    解压,然后运行

    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 而不是普通的 Windows msis 进行了“python 安装”。

I've been struggling with this same setup for the past week or so.

It looks to me like they have made some significant changes to how mercurial works in IIS recently, so the link above to Jeremy Skinners tutorial will be problematic for 1.7.2

This is a more recent link
I found I had to do a couple things differently.

These instructions are for 1.7.x, if you're using 1.8.x, be sure to read Ethan's comment below!

I followed the instructions in the comments of /contrib/win32/hgwebdir_wsgi.py.

  • Install Python 2.6.6

  • Add Python to system PATH (to make
    life easier)

  • Install pywin32 v214 (using the
    Python installer, Important!) (Note
    that this is built against python
    2.6)

  • Install isapi_wsgi

  • download the mercurial source package
    Extract, Then Run

    python setup.py --pure build_py -c -d . build_ext -i build_mo --force
    python setup.py --pure install --force
    
  • Copy hgwebdir_wsgi.py from /contrib/win32 to the folder you want to host it from.

  • Create a file hgweb.config in the folder you're going to host from. Add the contents

    [paths]
    yourRepoName = c:\yourRepoLocation
    
  • Edit hgwebdir_wsgi.py to point the
    hgweb.config. path_prefix is 0 if hg
    is the root of the website. if
    you're putting it in a vdir 1 deep,
    then it's 1, etc.

  • Run python hgwebdir_wsgi.py to create
    the isapi dll _hgwebdir_wsgi.dll.
    Console should print out
    "installation complete"

  • Create your app pool in IIS (no
    managed code)

  • Create your website, with the folder
    set to the same folder as
    hgwebdir_wsgi.py

  • Add Handler of type Module, use "*"
    as the mapping, select
    _hgwebdir_wsgi.dll as the executable, select isapimodule as the type,
    Mercurial-ISAPI as the name (although
    name doesn't really matter)

  • Edit feature permissions of the
    module to allow execute.

web.config (for the previous 2 steps):

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

After all this, I was able to get it working.

One last thing, I did copy MFC71.dll to windows/system32, although I'm not sure it was necessary
http://python.net/crew/skippy/win32/

I think the main difference between what I've got here and what's on the above link is that I did the "pure python" mercurial install, Although I'm a complete python newbie so I'm not sure. Also I did the "python installs" for pywin and isapi_wsgi rather than the plain windows msis.

贱贱哒 2024-10-12 15:40:49

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

Adam Boddington has written an updated installation description that works now: http://stackingcode.com/blog/2011/02/24/running-a-mercurial-server-on-iis-7-5-windows-server-2008-r2

寂寞陪衬 2024-10-12 15:40:49

我写了最多有关如何使用当前版本的 Mercurial (1.8.x) 以及当前版本的 Python (2.7) 在 IIS7 上设置 Mercurial 存储库的日期说明

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

I wrote out up to date instructions on how to setup a mercurial repository on IIS7 using the current versions of Mercurial (1.8.x) as well the current version of Python (2.7).

This will work for you and I appreciate if you use it to vote the answer up (or down ;)).

青丝拂面 2024-10-12 15:40:49

我之前确实犯了很多错误。
卸载所有 python、pywin32、isapi_wsgi,然后像上面一样安装它。
它的工作轻而易举。
吕克

I did have a lot of errors before.
Uninstalled all python, pywin32, isapi_wsgi an dinstalled it like above.
It worked as a breeze.
Luc

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