さくらにmercurialインストールしてhgwebでhttp公開する

ほぼまっさら状態のさくらインターネットスタンダードプランでmercurialというバージョン管理システムを入れてhgwebで公開もするところまで。
全部で5MBほどしか使わないので、サーバー容量にもやさしい。


こんな感じで公開した。これから公開プロジェクトが増えたらprojectsの下にhgwebを増やしていけば多分いい。
http://shokai.org/projects/chumby/twitter/hg/


まずさくらスタンダードが共有サーバーだと、pythonのライブラリをユーザ領域だけに入れたりする設定が面倒だったので
virtual-pythonでもう一つpython環境を作った。
virtual-python入れる - shokaiの日記


easy_installというpythonのパッケージ管理ツールを入れる(aptやgemやcpanのようなもの)
easy_install mercurialmercurialが入り、hgコマンドが使えるようになった
easy_install入れて、mercurialも入れる - shokaiの日記


hgweb.cgiというのがmercurialソースコードに入っていた。
コレをどこでも好きなweb公開ディレクトリに置いて、中身を編集してmercurialリポジトリを指定してやるとリポジトリをwebに公開できる。
http://d.hatena.ne.jp/s-yano/20080426/p2 を参考に


hgweb.cgi (短いのでこれで全部)
usernameの所は適宜さくらのユーザー名に変更してね

#!/home/username/bin/python
#
# An example CGI script to use hgweb, edit as necessary

# adjust python path if not a system-wide install:
import sys
#sys.path.insert(0, "/home/username/lib/python2.4/")

# enable importing on demand to reduce startup time
from mercurial import demandimport; demandimport.enable()

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb
#cgitb.enable()

# If you'd like to serve pages with UTF-8 instead of your default
# locale charset, you can do so by uncommenting the following lines.
# Note that this will cause your .hgrc files to be interpreted in
# UTF-8 and all your repo files to be displayed using UTF-8.
#
import os
os.environ["HGENCODING"] = "UTF-8"

from mercurial.hgweb.hgweb_mod import hgweb
import mercurial.hgweb.wsgicgi as wsgicgi

application = hgweb("path/to/repository", "repository name")
wsgicgi.launch(application)

application = hgweb の所でリポジトリを指定する。
適宜index.cgiなどに改名するとか、Basic認証をかけるなどする。


さくらはpythoncgiとして使う設定が済んでいるらしいので、パーミッションを755にするだけでwebブラウザからリポジトリを見れる。

http経由でリポジトリを読み書きもできるようになった