LoginSignup
1
1

More than 3 years have passed since last update.

NginxでPassenger+GridFSのビルド

Posted at

nginx + Passenger を使う場合は gem install passenger によるpassengerインストール後に使用できる passenger-install-nginx-module コマンドを実行して nginx をビルド&インストールするのが便利ですよね。
nginxのビルド時にオプションを指定でき、passenger + nginxでオプションを指定してビルドする の記事で紹介されているものが参考になります。

本記事では、MongoDBのGridFSをnginxで使用するための方法を記載します。

nginx-gridfsモジュールの用意

https://github.com/mdirolf/nginx-gridfs に書かれている手順で展開します。

$ cd /path/to     # 任意のパスを指定
$ git clone https://github.com/mdirolf/nginx-gridfs
$ cd nginx-gridfs
$ git submodule init
$ git submodule update

Nginxのビルド

--extra-configure-flags オプションで以下のように指定する。
上記で用意したnginx-gridfsへのパスを指定する。

$ passenger-install-nginx-module --extra-configure-flags="--add-module=/path/to/nginx-gridfs/"

Nginx設定への追加

以下のようにGridFS設定をNginx設定ファイルに記載します。

location /gridfs/ {
    gridfs my_app field=filename type=string;
    mongo 127.0.0.1:27017;
}
1
1
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
1
1