代码之家  ›  专栏  ›  技术社区  ›  Kevin Berridge

如何在IIS上设置Mercurial和hgwebdir?

  •  72
  • Kevin Berridge  · 技术社区  · 16 年前

    我一直在到处寻找关于如何让hgweb在IIS上工作的合理说明,但我没有发现多少有价值的东西。

    this "step by step" 还有 this this

    10 回复  |  直到 5 年前
        1
  •  49
  •   Vadim Kotov First Zero    8 年前

    我昨天刚刚安装了一个新的Mercurial实例,下面是1.7的更新说明:

    1. Install Mercurial
    2. Install Python (对于Mercurial 1.7,必须使用Python2.6.6的x86版本)
    3. 您需要下载hgweb。Mercurial源中的cgi文件。您可以通过运行以下命令下载源代码: hg clone https://www.mercurial-scm.org/repo/hg/
      • hgweb。cgi文件
      • 图书馆的内容。从“C:\Program Files\Mercurial”文件夹压缩
      • “C:\Program Files\Mercurial”中的模板文件夹
      • 通过以下方式启用CGI:控制面板->打开或关闭Windows功能->角色->Web服务器(IIS)->添加角色服务->检查CGI
      • 在IIS中创建新网站,并确保物理路径是您在上面创建的文件夹
      • *.cgi 对于请求路径, c:\Python26\python。exe-u“%s” 对于可执行文件,以及 python 为了名字。
    4. [收集]
      c:\Mercurial\repos=c:\Mercurial\repos

    5. config=“C:\Mercurial\hgweb.config”

    6. http://localhost/mercurial/hgweb.cgi (或者您在IIS中设置的适当URL路径)并且您应该看到Mercurial Repositories页面。

    还有,看看 Jeremy Skinners blog post

        2
  •  34
  •   Ken Pespisa    14 年前

    似乎自从Mercurial 1.5.2发布以来,这些教程就不能完全正常工作。首先,hgwebdir。cgi已被删除,现在被hgweb取代。cgi。

    对我最有效的说明是 eworldui.net :

    http://www.eworldui.net/blog/post/2010/04/08/Setting-up-Mercurial-server-in-IIS7-using-a-ISAPI-module.aspx

    这些说明适用于IIS 7或更高版本。如果您是在IIS 6上设置的,我编写了类似的针对Win2k3和IIS 6.0的说明:

    http://partialclass.blogspot.com/2010/05/setting-up-mercurial-server-on-win2k3.html

    在实现这一点后不久,我了解到BitBucket改变了其定价方案,提供免费、无限制的私人托管: https://bitbucket.org/

        3
  •  12
  •   BenAlabaster    14 年前

    我发现这篇博文在 Vampire Basic 这是一个很好的开始,但它并没有为我所追求的内容提供足够的细节。

    我写了一篇由4部分组成的博客文章,让您从零开始使用IIS,包括Active Directory集成、为推/拉设置安全特权、自定义模板,我将在这里复制它,但Mercurial的设计目的是在Linux/Apache上托管,这是一个相当冗长的问题:

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

        4
  •  11
  •   Ben Schwehn    16 年前
        5
  •  11
  •   Vadim Kotov First Zero    8 年前

    下面是我在为获取hgwebdir做了大量研究之后所做的工作。IIS6上的cgi设置。它基于以下站点:

    您需要在服务器上安装以下组件:

    • Mercurial(我使用的是1.5版)
    • Python 2.6。Python的版本取决于安装的Mercurial版本。 Mercurial 1.5使用Python 2.6。即使运行x64,也要安装x86。

    我的步骤是:

    • 为网站创建一个目录。我使用了c:\inetpub\wwwroot\hg。
    • 在IIS中,右键单击hg文件夹,选择属性,选择主目录选项卡。
    • 单击创建应用程序按钮。将执行权限设置为“脚本”。
    • 在目录安全选项卡中,单击身份验证和访问控制部分中的编辑按钮。取消选中所有身份验证方法,然后选中“基本身份验证”方法。如果要将默认域设置为Active Directory域,请将其设置为默认域。
    • 在IIS中,单击左侧面板上的“Web服务扩展”文件夹。单击“添加新的Web服务扩展”链接。扩展名应为Python,所需文件为c:\Python26\Python。exe-u“%s”%s。确保新的扩展是“允许的”。

    现在是测试Python是否正常工作的好时机。在新的Hg文件夹中创建一个名为test的文件。cgi。粘贴以下python代码:

    print 'Status: 200 OK'
    print 'Content-type: text/html'
    print
    
    print '<html><head>'
    print ''
    print '<h1>It works!</h1>'
    print ''
    print ''
    

    例如,打开网站的浏览器, http://localhost/hg/test.cgi

    你应该看到“它起作用了!”在浏览器中。

    • 删除测试。cgi
    • 将hg repo克隆到新目录: https://www.mercurial-scm.org/repo/hg/
    • 编辑文件并进行更改
    application = hgwebdir('hgweb.config')
    wsgicgi.launch(application)
    

    application = hgwebdir('c:\inetpub\wwwroot\hg\hgweb.config')
    wsgicgi.launch(application)
    
    • 将模板目录从c:\Program Files\Mercurial\templates\复制到c:\inetpub\wwwroot\hg\templates\
    • 创建一个名为hgweb的文件。在web目录中配置。

    现在是检验它的好时机。在浏览器中转到以下URL, http://localhost/hg/hgwebdir.cgi

    • 编辑hgweb。配置,然后粘贴以下内容:
    [collections]
    \\server\share$\Hg\ = \\server\share$\Hg\
    [web]
    allow_push = *
    push_ssl = false
    

    这些都是我的首选项,例如,我们的repo位于\\server\share$\Hg的子目录中。web应用程序将在登录用户通过浏览器的权限下运行,因此他们需要对共享具有读/写权限。

    最后一步是允许在首次克隆repo时发生长连接。运行以下命令将超时时间增加到50分钟:

    cd \inetpub\AdminScripts\
    cscript adsutil.vbs GET /W3SVC/CGITimeout 
    cscript adsutil.vbs SET /W3SVC/CGITimeout 3000
    
        6
  •  3
  •   Vadim Kotov First Zero    8 年前

    使用mercurial克隆mercurial存储库:

    hg clone https://www.mercurial-scm.org/repo/hg/
    

    您将找到hgwebdir。顶级cgi。它应该安装 和其他cgi脚本一样。

        7
  •  2
  •   Community CDub    8 年前

    在过去一周左右的时间里,我一直在为mercurial 1.7.2的这种设置而斗争,为了让它工作,我不得不做一些与上述文章稍有不同的事情。

    在这里发帖是因为谷歌一直把我带回这里。。。。

    完整说明 posted here

    我遵循了一系列的原则 these instructions these (in the source)

    主要的区别是我必须做 "pure python" install of mercurial 否则它会抱怨缺少DLL,我发现为pywin和isapi wsgi使用“python安装程序”很重要。(也许这对经验丰富的python开发人员来说是显而易见的,但我是python新手,所以这对我来说是新闻)

    希望这对某人有所帮助,我不是在瞎编(我可能是,就像我说的,python新手)

        8
  •  1
  •   Kevin Berridge    15 年前

    hg红皮书包含一些比我在其他地方看到的更好的一般说明。它们不是针对IIS的,但非常好:

    http://hgbook.red-bean.com/read/collaborating-with-other-people.html#sec:collab:cgi

        9
  •  1
  •   Tony Yates    14 年前

    我遇到一个“…无法加载模块…”输入错误,经过一些阅读,我的关键是忽略库。压缩Mercurial文件夹中的文件,而使用C:\Program Files(x86)\TortoiseHg文件夹中的文件。

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

    希望这对某人有帮助。。。

        10
  •  0
  •   marlboro    4 年前

    我知道这是一个老问题,但我真的很难在服务器2019和IIS 10上安装Hg。以下是我为使其工作所做的:

    1. 安装 在我的情况下是 python-2.7.18。amd64。微星 .我假设它安装在C:\Python27中。确保将python添加到您的路径中,并且安装了pip。

    2. 在命令行中使用pip将Mercurial作为模块安装:

    pip install mercurial
    
    1. 在下面 添加一个名为“hg”的新应用程序,并将其指向要使用的目录。

    2. 在IIS 10.0中将Python配置为此新网站(或整个web服务器,如果您愿意)的CGI处理程序。您可以手动执行此操作,也可以将以下内容创建/添加到 网状物配置 文件:

    <system.webServer>
        <handlers accessPolicy="Read, Script">
            <add name="Python 2.7" path="*.cgi" verb="*" modules="CgiModule" scriptProcessor="C:\Python27\python.exe -u &quot;%s&quot;" resourceType="File" />
        </handlers>
    </system.webServer>
    
    1. 在“hg”应用程序文件夹中创建 hgweb。cgi 这看起来类似于以下内容:
    #!/usr/bin/env python3
    #
    # An example hgweb CGI script, edit as necessary
    # See also https://mercurial-scm.org/wiki/PublishingRepositories
    
    # Path to repo or hgweb config to serve (see 'hg help hgweb')
    config = "hgweb.config"
    
    # Uncomment and adjust if Mercurial is not installed system-wide
    # (consult "installed modules" path from 'hg debuginstall'):
    # import sys; sys.path.insert(0, "/path/to/python/lib")
    
    # 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(config)
    wsgicgi.launch(application)
    
    1. hgweb。配置 将其归档并指向您的回购协议,如下所示:
    [collections]
    C:\Web\www\hg\repos\ = C:\Web\www\hg\repos\
    
        11
  •  -1
  •   Anton Gogolev    12 年前

    你可以试试 HgLab