LoginSignup
9
9

More than 5 years have passed since last update.

nginx-buildでnginxをビルドする

Last updated at Posted at 2014-05-24

mysql-buildxbuildのnginx版みたいなものをGoで書いてみた。

nginx単体のビルドは大して難しいものではないんだけど、
サードパーティモジュールやzlib、PCRE、OpenSSLといった依存ライブラリを静的に組み込もうとすると色々と面倒になってくるので、そのあたりを自動化したいと思ったのが開発の動機。言語がGoなのは完全に趣味。最初は頑張ってシェルスクリプトで書こうとしたが、完成形が定まっていないプロトタイピングの段階で生産性の低いツールを使うのはしんどかったのでやめた。

インストール

nginx-buildはGoで書かれているのでまずはGoが必要。Goがインストールされていれば以下のコマンドでインストールは完了する。

$ go get -u github.com/cubicdaiya/nginx-build  

nginx-buildでnginxをビルドする

では早速nginx-buildでnginxをビルドしてみよう。

$ uname
Darwin
$ nginx-build -v 1.9.7 -d work
nginx-build: 0.6.2
Compiler: gc go1.5.2
2015/12/08 04:55:03 Download nginx-1.9.7.....
2015/12/08 04:55:05 Extract nginx-1.9.7.tar.gz.....
2015/12/08 04:55:05 Generate configure script for nginx-1.9.7.....
2015/12/08 04:55:05 Configure nginx-1.9.7.....
2015/12/08 04:55:12 Build nginx-1.9.7.....
2015/12/08 04:55:16 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

2015/12/08 04:55:16 Enter the following command for install nginx.

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

実行経過を詳細に出力するには-verboseオプションを使う。

nginx-build -v 1.9.7 -d work -verbose

nginx-buildでnginxのビルドオプションを指定する

nginx-buildでnginxのconfigureに付加するオプションを変更するにはまず自前のconfigureを実行するシェルスクリプトファイルを用意する。

myconfigure.sh
#!/bin/sh                                                                                                                                                     

./configure \
--with-http_gunzip_module \

-cでこのファイルを指定して再度実行する。

nginx-build -v 1.9.7 -d work -c myconfigure.sh
nginx-build: 0.6.2
Compiler: gc go1.5.2
2015/12/08 04:57:52 Download nginx-1.9.7.....
2015/12/08 04:57:54 Extract nginx-1.9.7.tar.gz.....
2015/12/08 04:57:54 Generate configure script for nginx-1.9.7.....
2015/12/08 04:57:54 Configure nginx-1.9.7.....
2015/12/08 04:58:01 Build nginx-1.9.7.....
2015/12/08 04:58:05 Complete building nginx!

nginx version: nginx/1.9.7
built by clang 7.0.0 (clang-700.1.76)
configure arguments: --with-http_gunzip_module

2015/12/08 04:58:05 Enter the following command for install nginx.

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

ゆくゆくはこれをベースにnginxenvとか作れるといいのかもしれない。

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