2010-03-11 100 views
6

我試圖託管使用Scriptalias的Mercurial HG存儲庫。通過VisualSVN服務器託管Mercurial HG

的ScriptAlias/HG/「的htdocs/hgwebdir.cgi」

如果我去到Chrome它顯示CGI文件的內容。在IE中,它會渲染圖像和鏈接,但不會顯示。在任何一種情況下,我想要顯示的存儲庫都不顯示。

有沒有人設法使VisualSVN得到這個工作?如果我有Windows身份驗證和https,這也會工作嗎?

+0

我已經想現在摸不着頭腦了兩天!希望我有一個答案。 – 2010-04-08 20:43:08

+0

您必須爲ScriptAlias的最後一個參數使用絕對路徑。 – 2010-04-10 03:54:37

回答

7

下面是使用mod_wsgi(fast!),組合存儲庫目錄的替代設置,您可以從VisualSVN Server GUI管理Mercurial存儲庫級別訪問。

下載mod_wsgi.so for Apache 2.2 Win32並放置在「C:\ Program Files \ VisualSVN Server \ bin」中。

將hgwebdir.wsgi從您的Mercurial安裝(contrib目錄)複製到「C:\ Program Files \ VisualSVN Server \」。它應該是這個樣子:

import sys 
sys.path.insert(0, "C:\Program Files\Mercurial\library") 
from mercurial.hgweb.hgwebdir_mod import hgwebdir 
application = hgwebdir('hgweb.config') 

創建配置文件 「C:\ Program Files文件\ VisualSVN服務器\ hgweb.config」。

[paths] 
/= c:/Repositories/* 

將以下內容粘貼到「C:\ Program Files \ VisualSVN Server \ conf \ httpd-custom.conf」中。您應該根據httpd.conf的部分調整Auth *值。

LoadModule wsgi_module bin/mod_wsgi.so 
WSGIScriptAlias /hg "hgwebdir.wsgi" 

<Location /hg/> 
    AuthName "Mercurial Repositories" 
    AuthType VisualSVN 
    AuthzVisualSVNAccessFile "C:/Repositories/authz-windows" 
    AuthnVisualSVNBasic on 
    AuthnVisualSVNIntegrated off 
    AuthnVisualSVNUPN Off 

    SVNParentPath "C:/Repositories/" 

    require valid-user 
</Location> 

創建Mercurial庫:

hg init C:\Repositories\hgtest 

您現在應該能夠通過VisualSVN服務器工具,通過瀏覽器訪問/ Hg和管理儲存庫級授權。

+0

我覺得我非常接近這個工作,但是我收到一個錯誤'處理WSGI腳本mercurial發生異常'和'文件'mercurial \\ hgweb \\ hgwebdir_mod.pyc「,第103行,在__call__'。最新的Mecurial 1.5.1針對Python 2.6編譯? – dvkwong 2010-04-11 16:57:46

+0

發佈我最後的評論5秒後我終於得到了這個工作!根據以前的答案複製模板文件夾到庫文件夾 需要額外步驟: 1.提取庫。拉鍊的水銀安裝到一個文件夾,名爲庫 2.複製模板文件夾到庫文件夾 3.確保你安裝Python 2.6 感謝 – dvkwong 2010-04-11 17:04:08

+1

FYI:。!包括在VisualSVN服務器分配的mod_wsgi模塊,因爲3.3.0版本:https://www.v isualsvn.com/server/changes/#v3.3.0 – 2015-09-03 19:34:34

0

您可以在不同身份驗證和https模塊後面運行hgwebdir,只要您的網絡服務器在REMOTE_USER變量交給CGI之前處理它們即可。

我不知道visualsvn,但你的ScriptAlias看起來很像Apache。你需要一個AddHandler行.cgi嗎?

+0

AddHandler行應該是在常規apache服務器上執行CGI所需的全部內容嗎? – 2010-04-08 21:21:45

+0

在Apache中,您可以使用「ExecCGI」,「AddHandler cgi-script .cgi」和「ScriptAlias」來授權執行文件。我用後兩個。 – 2010-04-08 23:16:32

3

假設你已經安裝並運行了Python 2.6,下面是我採取的步驟。

獲取爲「Apache 2.2 Win32」構建的「mod_cgi.so」,並將其放在「C:\ Program Files \ VisualSVN Server \ bin」中。

粘貼下面在 「C:\ Program Files文件\ VisualSVN服務器\的conf \的httpd-custom.conf」

LoadModule cgi_module bin/mod_cgi.so 
ScriptAliasMatch ^/hg(.*) "cgi-bin/hgweb.cgi$1" 

創建cgi-bin目錄「C:\ Program Files文件\ VisualSVN服務器\ cgi-bin目錄」。並在其中放置hgweb.cgi。確保它看起來類似於以下內容:

#!c:/Python26/python.exe -u 

import sys 
sys.path.insert(0, "C:\Program Files\Mercurial\library") 

import cgitb 
cgitb.enable() 

from mercurial.hgweb.hgwebdir_mod import hgwebdir 
import mercurial.hgweb.wsgicgi as wsgicgi 

application = hgwebdir('hgweb.config') 
wsgicgi.launch(application) 

在cgi-bin目錄中創建一個名爲hgweb.config的文件。

[paths] 
/= c:/HgRepositories/* 

將「C:\ Program Files \ Mercurial \ templates」複製到「C:\ Program Files \ Mercurial \ library \ templates」中。

創建「C:\ HgRepositories」文件夾和「hg init c:\ HgRepositories \ test」。

重新啓動VisualSVN服務器,打開瀏覽器,享受您的Mercurial存儲庫。

1

從Mercurial的1.6版開始,hgwebdir.wsgi腳本將 與hgweb.wsgi腳本統一起來。無論hgwebdir.wsgi是否在這些方向中提到的 ,都可以用hgweb.wsgi 腳本代替。

https://www.mercurial-scm.org/wiki/modwsgi