2012年5月9日 星期三

Setup Private Git Server like github (RhodeCode)

System info: Debian 6.0、Python 2.7.3、Lighttpd 1.4.28、Rhodecode 1.3.4



系統架構圖

目標:使用者可透過網際網路使用HTTP或HTTPS存取Git版本庫或RhodeCode的專案介面

遇到的問題:

  1. RhodeCode欲使用80 port提供服務必須使用root權限執行,本身不具備啟動後切換身分的功能

  2. RhodeCode內建的Web Server不支援SSL

  3. Git Client使用HTTPS時如果無法驗證憑證(自簽憑證)會終止




安裝RhodeCode

可參考 http://packages.python.org/RhodeCode/setup.html

  1. 只要使用easy_install rhodecode 就可以了;預設使用Sqlite儲存資料,如果怕效能問題要存到Mysql或pgsql別忘了安裝python的driver

  2. 建立設定時使用非root執行會有錯誤
    paster make-config RhodeCode production.ini

  3. 修改production.ini設定檔


    1. host 預設是127.0.0.1,修改為0.0.0.0監聽所有介面

    2. sqlalchemy.db1.url預設為sqlite:///%(here)s/rhodecode.db,指的是設定檔同層目錄的rhodecode.db

  4.  儲存設定檔後執行初始化,如果您不想使用root執行rhodecode,執行這個動作前應切換為該user
    paster setup-app production.ini

    初始化期間會建立預設的管理者帳號密碼,以及版本庫存放路徑(請事先建立該目錄)

  5. 啟動服務
    paster serve production.ini

    打開瀏覽器http://your-hostname:5000就可以看到RhodeCode的畫面了

  6. init script,可以在RhodeCode的版本庫中找到幾個,目前使用的是 rhodecode-daemon2
    https://secure.rhodecode.org/rhodecode/files/2d35bbff7c358c49651c80e431493b57a2aec701/init.d



原則上如果您是在LAN提供服務或者不是很在乎安全性這樣就可以使用了

如果是要跨網際網路使用建議加上SSL比較安全,而且rhodecode不要使用root的身分執行

因為rhodecode本身並不支援SSL,所以要加上SSL必須前面有個支援SSL的Web Server當反向代理(reverse proxy)

Lighttpd只需要使用proxy模組再設定一下即可
$HTTP["host"] == "code.null.tw" {
        proxy.server= ( "" => ((
                                "host" => "127.0.0.1",
                                "port" => 8080
                                 ) ))
}

最後,Server端都就緒之後就是Client了,這邊會有兩個狀況

  1. 預設Git extenstions使用HTTPS連線時詢問密碼是在console不是跳出GUI輸入框
    這個問題已經被問爛了https://github.com/spdr870/gitextensions/issues/251
    打開git bash命令列執行 git config --system core.askpass git-gui--askpass 即可

  2. 如果HTTPS使用的是自簽憑證(Self Signed SSL Certificates) Git會跳出無法驗證憑證發行單位拒絕連線
    這個問題大部分解法都是直接關掉git驗證SSL憑證發行單位,感覺不是很妥當,想比照瀏覽器匯入憑證的方式處理
    但是git並非使用瀏覽器的憑證清單,需下載SSL憑證修改 .gitconfig 加上 修改版本庫目錄.git/config
    [http]
    sslCAinfo = C:/Users/nansen/code.null.tw.crt

1 則留言:

  1. In Washington state, for instance, sports activities betting is authorized only in individual on tribal on line casino property. In Montana, cellular betting can take place only when the consumer is bodily inside a on line casino. Washington, D.C., has comparable geographical restrictions — usage of the BetMGM app, for instance, is restricted to within a few of} blocks of Nationals Park, the city’s MLB stadium. South Dakota permits sports activities betting in one 로스트아크 of the limited contexts in the entire nation. Sports betting within the Mount Rushmore State is confined to land-based casinos in Deadwood. It is feasible that tribal places within the state may also open sportsbooks of their own, but no cellular sports activities betting is feasible right now.

    回覆刪除