Skip to content

nginx-plus/nginx-build

 
 

Repository files navigation

nginx-build

nginx-build - provides a command to build nginx seamlessly.

gif

Requirements

  • git and hg for downloading 3rd party modules
  • patch for applying patch to nginx

Build Support

Installation

go install github.com/cubicdaiya/nginx-build@latest

Quick Start

nginx-build -d work

Custom Configuration

nginx-build provides a mechanism for customizing configuration for building nginx.

Configuration for building nginx

Prepare a configure script like the following.

#!/bin/sh

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

Give this file to nginx-build with -c.

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

Direct configuration for building nginx

In the v0.4.0 or later, nginx-build allows to use nginx's configure options directly.

$ 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_v2_module \
--with-http_ssl_module \
--with-pcre-jit \

But there are limitations. See here about details.

About --add-module and --add-dynamic-module

nginx-build allows to use multiple --add-module and --add-dynamic-module.

$ nginx-build \
-d work \
--add-module=/path/to/ngx_dynamic_upstream \
--add-dynamic-module=/path/to/ngx_small_light

On the other hand, nginx-build allows to embed multiple 3rd party modules with the single --add-module and --add-dynamic-module like the following, too.

$ nginx-build \
-d work \
--add-module=/path/to/ngx_small_light,/path/to/ngx_dynamic_upstream

Limitations

There are the limitations for the direct configuration below.

  • --with-pcre(force PCRE library usage) is not allowed
  • --with-pcre=DIR(set path to PCRE library sources) is allowed
  • --with-libatomic(force libatomic_ops library usage) is not allowed
  • --with-libatomic=DIR(set path to libatomic_ops library sources) is allowed

The limitations above are attributed by the flag package of Go. (multiple and different types from each other are not allowed) By the way, the options above are allowed in a prepared configure script, of course.

Embedding zlib statically

Give -zlib to nginx-build.

$ nginx-build -d work -zlib

-zlibversion is an option to set a version of zlib.

Embedding PCRE statically

Give -pcre to nginx-build.

$ nginx-build -d work -pcre

-pcreversion is an option to set a version of PCRE.

Embedding OpenSSL statically

Give -openssl to nginx-build.

$ nginx-build -d work -openssl

-opensslversion is an option to set a version of OpenSSL.

Embedding LibreSSL statically

Give -libressl to nginx-build.

$ nginx-build -d work -libressl

-libresslversion is an option to set a version of LibreSSL.

Embedding 3rd-party modules

nginx-build provides a mechanism for embedding 3rd-party modules. Prepare a ini-file below.

[ngx_http_hello_world]
form=git
url=https://github.com/cubicdaiya/ngx_http_hello_world

Give this file to nginx-build with -m.

$ nginx-build -d work -m modules.cfg.example

Embedding 3rd-party module dynamically

Give dynamic=true.

[ngx_http_hello_world]
form=git
url=https://github.com/cubicdaiya/ngx_http_hello_world
dynamic=true

Provision for 3rd-party module

There are some 3rd-party modules expected provision. nginx-build provides the options such as shprov and shprovdir for this problem. There is the example configuration below.

[njs/nginx]
form=hg
url=https://hg.nginx.org/njs
shprov=./configure && make
shprovdir=..

Applying patch before building nginx

nginx-build provides the options such as -patch and -patch-opt for applying patch to nginx.

nginx-build \
 -d work \
 -patch something.patch \
 -patch-opt "-p1"

Idempotent build

nginx-build supports a certain level of idempotent build of nginx. If you want to ensure a build of nginx idempotent and do not want to build nginx as same as already installed nginx, give -idempotent to nginx-build.

$ nginx-build -d work -idempotent

-idempotent ensures an idempotent by checking the software versions below.

  • nginx
  • PCRE
  • zlib
  • OpenSSL

On the other hand, -idempotent does not cover versions of 3rd party modules and dynamic linked libraries.

Build OpenResty

nginx-build supports to build OpenResty.

$ nginx-build -d work -openresty -pcre -openssl

If you don't install PCRE and OpenSSL on your system, it is required to add the option -pcre and -openssl.

And there is the limitation for the support of OpenResty. nginx-build does not allow to use OpenResty's unique configure options directly. But you can use the common options of nginx and OpenResty directly. If you want to use OpenResty's unique configure option, Configuration for building nginx is helpful.

Build Tengine

nginx-build supports to build Tengine.

$ nginx-build -d work -tengine -openssl

If you don't install OpenSSL on your system, it is required to add the option -openssl.

There is the limitation for the support of Tengine. nginx-build does not allow to use Tengine's unique configure options directly. But you can use the common options of nginx and Tengine directly.

About

Seamless nginx builder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.2%
  • Other 0.8%