Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/njs/install.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Nginx, Inc.
5
-->
6
7
<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8
9
<article name="Download and install"
10
link="/en/docs/njs/install.html"
11
lang="en"
12
rev="5">
13
14
<section id="install_package" name="Installing as a Linux package">
15
16
<para>
17
For Linux, njs modules
18
<link doc="../../linux_packages.xml" id="dynmodules">packages</link> can be used:
19
<list type="bullet">
20
21
<listitem>
22
<literal>nginx-module-njs</literal> — njs
23
<link doc="../ngx_core_module.xml" id="load_module">dynamic</link> modules
24
</listitem>
25
26
<listitem>
27
<literal>nginx-module-njs-dbg</literal> — debug symbols for the
28
<literal>nginx-module-njs</literal> package
29
</listitem>
30
31
</list>
32
</para>
33
34
<para>
35
After package installation, njs dynamic modules need to be loaded with the
36
<link doc="../ngx_core_module.xml" id="load_module"><literal>load_module</literal></link>
37
directive:
38
<example>
39
load_module modules/ngx_http_js_module.so;
40
</example>
41
or
42
<example>
43
load_module modules/ngx_stream_js_module.so;
44
</example>
45
</para>
46
47
</section>
48
49
50
<section id="install_sources" name="Building from the sources">
51
52
<para>
53
The <link url="https://github.com/nginx/njs">repository</link>
54
with njs sources can be cloned with the following command
55
(requires <link url="https://git-scm.com/">Git</link> client):
56
<example>
57
git clone https://github.com/nginx/njs
58
</example>
59
Then the modules should be compiled from
60
<link doc="../configure.xml">nginx</link> root directory using the
61
<literal>--add-module</literal> configuration parameter:
62
<example>
63
./configure --add-module=<value>path-to-njs</value>/nginx
64
</example>
65
The modules can also be built as
66
<link doc="../ngx_core_module.xml" id="load_module">dynamic</link>:
67
<example>
68
./configure --add-dynamic-module=<value>path-to-njs</value>/nginx
69
</example>
70
</para>
71
72
<section id="install_quickjs" name="Adding QuickJS engine support">
73
74
<para>
75
Make sure you have built the QuickJS library:
76
<example>
77
git clone https://github.com/bellard/quickjs
78
cd quickjs
79
CFLAGS='-fPIC' make libquickjs.a
80
</example>
81
At the module compilation step, also
82
specify the include (<literal>-I</literal>) and library (<literal>-L</literal>)
83
paths with the
84
<literal>--with-cc-opt=</literal> and
85
<literal>--with-ld-opt=</literal> configuration parameters:
86
<example>
87
./configure --add-module=<value>path-to-njs</value>/nginx \
88
--with-cc-opt="-I <value>path-to-quickjs</value>" \
89
--with-ld-opt="-L <value>path-to-quickjs</value>"
90
</example>
91
</para>
92
93
</section>
94
95
</section>
96
97
98
<section id="cli" name="Building njs command-line utility">
99
100
<para>
101
To build only the njs command-line <link doc="cli.xml">utility</link>, run
102
<literal>./configure</literal> and <literal>make njs</literal> commands
103
from njs root directory.
104
After building, the utility is available as <literal>./build/njs</literal>.
105
</para>
106
107
</section>
108
109
</article>
110
111
112