2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nginx unitをmacで使う。【ruby(rbenv)編】

Last updated at Posted at 2019-09-23

macでnginx-unitを使うのにちょっと苦戦したのでメモ代わりに。

インストール

brewにはないのでソースからインストール
(公式を参照の上、ソースをダウンロード)
git clone https://github.com/nginx/unit
(ソースはどこでもOK)
ダウンロードしたフォルダに移動して、./configureを。
だいたい代表的なオプションは以下の通りかと。

configure options
--prefix=/usr/local/    →だいたいこのへんの場所でOK

フルになるとこんな感じ
./configure --prefix=/usr/local/ とか

ruby用のconfigure

今回はrubyを動かしたいので、
./configure ruby
も実行。
ここでrbenvからrubyをインストールしてる場合は、rbenvのバージョンと合わない場合あり。
(元から入ってるやつを指定してしまう?)

*参考
$ ./configure ruby
configuring Ruby module
checking for Ruby library ... found
checking for Ruby version ... 2.3.7
 + Ruby module: ruby.unit.so
(ほんとはrbenvで2.4.1のrubyが入ってる)

これはこのissueみて解決。
https://github.com/nginx/unit/issues/224
CONFIGURE_OPTS="--enable-shared" rbenv install 2.4.1
どうやらso作ってないと駄目なそうな。
ちなみに、--enable-sharedはダイナミックリンクライブラリを作るオプション。

build & install

make
make install
で入るはず。上のprefixでroot所有のフォルダだとsudo make installで。

起動

unitdでひとまず起動できる。
他のオプションは
https://unit.nginx.org/installation/#startup
を参照。
大体は、--control --log --pidあたりのオプションを付けるかな。
(デフォルトだとunix-socketになるので、--control 127.0.0.1:8080とかの方が楽かも。まぁテストだし。)

設定ファイルのPUTなど

これは公式を参照するほうが良い。railsはうまく起動できなかったりでハマリ気味。
https://unit.nginx.org/configuration/
JSONをunitdのcontrolにPUTしたりする。

configureオプションミスったり、変なのinstallしちゃったとき

make clean
make uninstall
で解決

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?