njs编译方法 - Thu, Mar 14, 2019
从nnjs源码编译安装njs
1. 下载代码
hg管理的源码库:
http://hg.nginx.org/njs/file/tip
github的只读库:
https://github.com/nginx/njs
2. 安装必要的编译软件
基本编译软件gcc
g++
cmake
automake
sudo apt-get install gcc g++ cmake automake
3. 安装必要的库文件
- openssl
sudo apt-get install openssl libssl-dev
- pcre
sudo apt-get install libpcre3 libpcre3-dev
- zlib
sudo apt-get install zlib1g-dev
- editline
sudo apt-get install libeditline-dev
- expect
sudo apt-get install expect
4. 配置njs编译环境
./configure
5. 编译
make njs
特别说明
如果要编译njs的module需要在nginx里里面进行编译 njs里面有一下两个modules:
ngx_http_js_module.c
ngx_stream_js_module.c
分别对应nginx配置环境里面的HTTP=YES
STREAM=NO
,默认STREAM是不会被编译需要打开编译选项。
配置编译环境之后,执行
动态链接库
./configure --add-dynamic-module=path-to-njs/nginx
静态链接库
./configure --add-module=path-to-njs/nginx
USE_THREADS=NO
NGX_FILE_AIO=NO
HTTP=YES
NGX_HTTP_LOG_PATH=
NGX_HTTP_CLIENT_TEMP_PATH=
NGX_HTTP_PROXY_TEMP_PATH=
NGX_HTTP_FASTCGI_TEMP_PATH=
NGX_HTTP_UWSGI_TEMP_PATH=
NGX_HTTP_SCGI_TEMP_PATH=
# STUB
HTTP_STUB_STATUS=NO
MAIL=NO
MAIL_SSL=NO
MAIL_POP3=YES
MAIL_IMAP=YES
MAIL_SMTP=YES
STREAM=YES
STREAM_SSL=NO
STREAM_REALIP=NO
STREAM_LIMIT_CONN=YES
STREAM_ACCESS=YES
STREAM_GEO=YES
STREAM_GEOIP=NO
STREAM_MAP=YES
STREAM_SPLIT_CLIENTS=YES
STREAM_RETURN=YES
STREAM_UPSTREAM_HASH=YES
STREAM_UPSTREAM_LEAST_CONN=YES
STREAM_UPSTREAM_RANDOM=YES
STREAM_UPSTREAM_ZONE=YES
STREAM_SSL_PREREAD=NO