LoginSignup
10
10

More than 5 years have passed since last update.

nginx-buildでnginxにサードパーティモジュールを組み込む

Last updated at Posted at 2014-05-24

nginxのサードパーティモジュール

nginxにサードパーティのモジュールを組み込むにはnginx本体のビルド時に静的に組み込む必要がある。これはApacheと比べてnginxの数少ないめんどくさい点のうちの一つだ。具体的には--add-moduleで組み込みたいモジュールのパスを指定する。

$ ./configure --add-module=サードパーティモジュールのパス

nginxに依存ライブラリを静的に組み込むのと同様にこれも少々めんどくさい。nginx-buildにはこの作業を自動化するための仕組みがある。

nginx-buildでnginxにサードパーティモジュールを組み込む

nginx-buildでサードパーティモジュールを組み込むには以下のようなiniファイルを用意する。

modules3rd.ini
[echo-nginx-module]
form=git
url=https://github.com/openresty/echo-nginx-module.git
rev=v0.58

[headers-more-nginx-module]
form=git
url=https://github.com/openresty/headers-more-nginx-module.git
rev=v0.28

あとはこのファイルを-mオプションで指定して実行。

$ nginx-build -v 1.7.0 -d work -m modules3rd.ini
nginx-build: 0.6.2
Compiler: gc go1.5.2
2015/12/08 04:52:49 Download headers-more-nginx-module-v0.28.....
2015/12/08 04:52:49 Download nginx-1.9.7.....
2015/12/08 04:52:49 Download echo-nginx-module-v0.58.....
2015/12/08 04:53:03 Extract nginx-1.9.7.tar.gz.....
2015/12/08 04:53:03 Generate configure script for nginx-1.9.7.....
2015/12/08 04:53:03 Configure nginx-1.9.7.....
2015/12/08 04:53:10 Build nginx-1.9.7.....
2015/12/08 04:53:15 Complete building nginx!

nginx version: nginx/1.9.7
built by clang 7.0.0 (clang-700.1.76)
configure arguments: --with-cc-opt=-Wno-deprecated-declarations --add-module=../echo-nginx-module --add-module=../headers-more-nginx-module

2015/12/08 04:53:15 Enter the following command for install nginx.

   $ cd work/nginx/1.9.7/nginx-1.9.7
   $ sudo make install

という風に指定したURLからgit cloneでダウンロードしてそのままnginxに組み込んでくれる。今のところgit clone以外でダウンロードできない場合については対応していない。

10
10
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
10
10