LoginSignup
3
2

More than 5 years have passed since last update.

nginx-buildでnginxのconfigureオプションを直接指定する

Last updated at Posted at 2015-06-09

nginx-buildとnginxのconfigureオプション

これまでnginx-buildでnginxのconfigureオプションを細かく指定するには別途./configureを実行するシェルスクリプトのファイルを用意しなければならなかった。そう、こんな風に。

nginx-configure
#!/bin/sh

./configure \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \

nginx-buildで上記の./configureを実行するには-cでこのシェルスクリプトファイルを与えてやる。

$ nginx-build -d work -c nginx-configure

このやり方はnginxのビルド方法をファイルに残せるという利点がある一方で面倒だった。
nginx-buildは元々数十台&数種類のnginxインスタンスをシームレスに構築および包括的に管理するための仕組みの一貫で開発した( & している)ものなのでこのようにビルドスクリプトをファイルに残すのは理にかなっているのだが、やはり面倒なものは面倒だ。単純にこうできるようにしたい。

$ nginx-build -d work \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--with-http_stub_status_module \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--with-debug \
--with-http_gzip_static_module \
--with-http_spdy_module \
--with-http_ssl_module \
--with-pcre-jit \

nginx-build-0.4.0

で、今日リリースしたnginx-0.4.0からこれができるようになった。

$ nginx-build -d work \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--with-http_stub_status_module \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--with-debug \
--with-http_gzip_static_module \
--with-http_spdy_module \
--with-http_ssl_module \
--with-pcre-jit

nginx-build: 0.4.0
Compiler: gc go1.4.2
2015/06/09 20:08:11 Download nginx-1.9.1.....
2015/06/09 20:08:13 Extract nginx-1.9.1.tar.gz.....
2015/06/09 20:08:13 Generate configure script for nginx-1.9.1.....
2015/06/09 20:08:13 Configure nginx-1.9.1.....
2015/06/09 20:08:19 Build nginx-1.9.1.....
2015/06/09 20:08:23 Complete building nginx!

nginx version: nginx/1.9.1
built by clang 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
built with OpenSSL 0.9.8zd 8 Jan 2015
TLS SNI support enabled
configure arguments: --with-cc-opt=-Wno-deprecated-declarations --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access.log --sbin-path=/usr/sbin/nginx --lock-path=/var/lock/nginx.lock --http-client-body-temp-path=/var/lib/nginx/body --with-http_spdy_module --with-http_stub_status_module --with-pcre-jit --with-http_ssl_module --with-http_gzip_static_module --with-debug

2015/06/09 20:08:23 Enter the following command for install nginx.

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

ちゃんとconfigure argumentsnginx-buildから指定したオプションが並んでいる。

--add-moduleによるサードパーティモジュールの組み込み

--add-moduleによるサードパーティモジュールの組み込みもできる。

$ nginx-build -d work --add-module=../nginx/ngx_small_light

ただ、nginx本体の--add-moduleとは若干仕様が異なる。以下のように--add-moduleを複数使用することはできない。

$ nginx-build -d work --add-module=../nginx/ngx_small_light --add-module=../nginx/ngx_dynamic_upstream
nginx-build: 0.4.0
Compiler: gc go1.4.2
2015/06/09 20:13:07 Download nginx-1.9.1.....
2015/06/09 20:13:10 Extract nginx-1.9.1.tar.gz.....
2015/06/09 20:13:10 Generate configure script for nginx-1.9.1.....
2015/06/09 20:13:10 Configure nginx-1.9.1.....
2015/06/09 20:13:15 Build nginx-1.9.1.....
2015/06/09 20:13:18 Complete building nginx!

nginx version: nginx/1.9.1
built by clang 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configure arguments: --with-cc-opt=-Wno-deprecated-declarations --add-module=/Users/bokko/workspace/nginx-build/../nginx/ngx_dynamic_upstream

2015/06/09 20:13:18 Enter the following command for install nginx.

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

nginxのビルドは成功するが、--add-moduleが一つだけになってしまう。これはnginx-buildが利用しているflagパッケージの制限によるもの。nginx-buildはこのためのワークアラウンドとして--add-moduleオプションにカンマ区切りで複数のモジュールパスを指定できるようにしてある。

$ nginx-build -d work --add-module=../nginx/ngx_small_light,../nginx/ngx_dynamic_upstream
nginx-build: 0.4.0
Compiler: gc go1.4.2
2015/06/09 20:15:14 Download nginx-1.9.1.....
2015/06/09 20:15:17 Extract nginx-1.9.1.tar.gz.....
2015/06/09 20:15:17 Generate configure script for nginx-1.9.1.....
2015/06/09 20:15:17 Configure nginx-1.9.1.....
2015/06/09 20:15:22 Build nginx-1.9.1.....
2015/06/09 20:15:25 Complete building nginx!

nginx version: nginx/1.9.1
built by clang 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configure arguments: --with-cc-opt=-Wno-deprecated-declarations --add-module=/Users/bokko/workspace/nginx-build/../nginx/ngx_small_light --add-module=/Users/bokko/workspace/nginx-build/../nginx/ngx_dynamic_upstream

2015/06/09 20:15:25 Enter the following command for install nginx.

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

その他の制限についてはこちらを参照。

3
2
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
3
2