Mongrel2をMacにインストールしてみた。

Mongrel2をMacにインストールしたメモ。

brew で ZeroMQをインストール

brew install zeromq

Mongrel2のBuild&インストール

$ cd /usr/src
$ wget http://mongrel2.org/static/downloads/mongrel2-1.0.tar.bz2
$ tar xvjf mongrel2-1.0.tar.bz2
$ make & make install

設定する。

適当な場所を実行場所にする。
ここはドキュメントと一緒
http://mongrel2.org/wiki?name=GettingStarted

$ mkdir ~/mongrel2
$ cd mongrel2
# run logs tmpディレクトリを作成
$ mkdir run logs tmp
# examplesから設定ファイルをコピーしてくる。
$ cp /usr/src/mongrel2-1.0/examples/python/tests/sample_conf.py myconfig.py

パスの関係か設定ファイルがこのままだと上手く動かなかったので、chrootを追加

    hosts = [
        Host(chroot="./", name="localhost", routes={
            r'/tests/': Dir(base='tests/', index_file='index.html',
                             default_ctype='text/plain')
        })
    ]

テストのために単純なファイルを置いておきます。

$ mkdir tests
$ vim tests/index.html
<html>
Hello World
</html>

これで ./tests以下にあるファイルを表示できるはず。

$ m2sh init -db myconfig.sqlite
$ m2sh load -db myconfig.sqlite  -config myconfig.py

起動

コマンドを叩いてみると一瞬で起動しました。

m2sh start -db myconfig.sqlite -host localhost

あとは

http://localhost:6767/tests/

のように叩けば Hello Worldが表示されるはず。