如何建立Mercurial(hg) Server + lighttpd 在ubuntu
如何建立Mercurial Server運行在ubuntu server版本機器上並且透過lighttpd server執行hgwebdir CGI。
安裝的步驟如下:
1. 安裝mercurial
sudo apt-get install mercurial
2. 設定hg repository 位置
cd /var/
sudo mkdir hg
sudo mkdir hg/repos
sudo chown -R www-data:www-data hg/repos
這個範例中,我將hg的repository建立在/var/hg/repos
3. 建立hgwebdir.cgi
cd /var/hg
sudo cp /usr/share/doc/mercurial/examples/hgweb.cgi .
sudo chmod a+x hgweb.cgi
修改範例CGI
使用文字編輯器修改一下"config ="這個設定,改成你所指定的位置,這邊接同時設定為/var/hg/hgweb.config
sudo nano hgweb.config
改為
config = "/var/hg/hgweb.config"
4. 建立hgweb.config
[collections]
/var/hg/repos = /var/hg/repos
[web]
allow_push = *
push_ssl = false
5. 建立使用者密碼
cd /var/hg
htpasswd -mc hgusers admin
6. 修改server modules
server.modules += ( "mod_cgi" )
server.modules += ( "mod_rewrite" )
url.rewrite-once = (
"^/hg([/?].*)?$" => "/hgwebdir.cgi$1",
"^/mercurial([/?].*)?$" => "/hgwebdir.cgi$1"
)
$HTTP["url"] =~ "^/hgwebdir.cgi([/?].*)?$" {
server.document-root = "/var/hg/"
cgi.assign = ( ".cgi" => "/usr/bin/python" )
}
檢測一下設定檔內容是否有錯誤:
$ sudo lighttpd -t -f /etc/lighttpd/lighttpd.conf
出現Syntax OK,就表示正確無誤。
7. 建立repository
cd /var/hg/repos
mkdir test
cd test
hg init
參考資料
留言
張貼留言