Download and install (original) (raw)
Installing as a Linux package
For Linux, njs modulespackages can be used:
nginx-module-njs
— njsdynamic modulesnginx-module-njs-dbg
— debug symbols for thenginx-module-njs
package
After package installation, njs dynamic modules need to be loaded with theload_moduledirective:
load_module modules/ngx_http_js_module.so;
or
load_module modules/ngx_stream_js_module.so;
Building from the sources
The repositorywith njs sources can be cloned with the following command (requires Git client):
git clone https://github.com/nginx/njs
Then the modules should be compiled fromnginx root directory using the--add-module
configuration parameter:
./configure --add-module=
_path-to-njs_
/nginx
The modules can also be built asdynamic:
./configure --add-dynamic-module=
_path-to-njs_
/nginx
Adding QuickJS engine support
Make sure you have built the QuickJS library:
git clone https://github.com/bellard/quickjs cd quickjs CFLAGS='-fPIC' make libquickjs.a
At the module compilation step, also specify the include (-I
) and library (-L
) paths with the--with-cc-opt=
and--with-ld-opt=
configuration parameters:
./configure --add-module=
_path-to-njs_
/nginx
--with-cc-opt="-I_path-to-quickjs_
"
--with-ld-opt="-L_path-to-quickjs_
"
Building njs command-line utility
To build only the njs command-line utility, run./configure
and make njs
commands from njs root directory. After building, the utility is available as ./build/njs
.