njs是Nginx的一个扩展,用于取代lua动态输出内容
njs融合了浏览器端的ES(如crypto
)语法和部分NodeJS语法(如fs.open
)
编译
将njs克隆到 njs/
文件夹中:
git clone https://github.com/nginx/njs.git
然后是重新编译nginx
./configure \
--prefix=/usr/local/osgi/ \
--sbin-path=bin/ \
--modules-path=lib/nginx/ \
--conf-path=etc/nginx/nginx.conf \
--error-log-path=/tmp/nginx/error.log \
--pid-path=/tmp/nginx/.pid \
--lock-path=/tmp/nginx/.lock \
--user=daemon \
--group=daemon \
--build="for ARMRounger" \
--without-poll_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_mirror_module \
--without-http_geo_module \
--without-http_map_module \
--without-http_split_clients_module \
--without-http_uwsgi_module \
--without-http_grpc_module \
--without-http_memcached_module \
--without-http_empty_gif_module \
--without-http_browser_module \
--without-http_upstream_hash_module \
--without-http_upstream_ip_hash_module \
--without-http_upstream_least_conn_module \
--without-http_upstream_random_module \
--without-http_upstream_keepalive_module \
--without-http_upstream_zone_module \
--http-log-path=/tmp/nginx/log.log \
--http-client-body-temp-path=/tmp/nginx/body \
--http-proxy-temp-path=/tmp/nginx/proxy \
--http-fastcgi-temp-path=/tmp/nginx/fcgi \
--http-scgi-temp-path=/tmp/nginx/scgi \
--with-cc=armv7m-linux-musleabi-gcc \
--with-cpp=armv7m-linux-musleabi-gcc-g++ \
--add-dynamic-module=njs/nginx/ \
--add-module=dav \
--with-http_dav_module \
--with-zlib=../zlib-1.3.1 \
--with-http_v2_module \
--with-http_v3_module
入坟第一步失败
>> cat build/autoconf.err
checking for C compiler: armv7m-linux-musleabi-gcc gcc version 11.2.1 20211120 (GCC)
checking for sizeof(int)
/bin/sh: 1: build/autotest: Exec format error
checking for sizeof(u_int)
/bin/sh: 1: build/autotest: Exec format error
checking for sizeof(void *)
/bin/sh: 1: build/autotest: Exec format error
checking for sizeof(uintptr_t)
/bin/sh: 1: build/autotest: Exec format error
checking for sizeof(size_t)
/bin/sh: 1: build/autotest: Exec format error
checking for sizeof(off_t)
/bin/sh: 1: build/autotest: Exec format error
checking for sizeof(time_t)
/bin/sh: 1: build/autotest: Exec format error
checking for system byte ordering
/bin/sh: 1: build/autotest: Exec format error
解决方法:
for i in `ls njs/auto`
do
sed -i 's|njs_feature_run=yes|njs_feature_run=no|g' njs/auto/$i
sed -i 's|njs_feature_run=value|njs_feature_run=no|g' njs/auto/$i
done
完美:
configuring additional dynamic modules
adding module in ../njs/nginx/
enabled webcrypto module
enabled xml module
enabled zlib module
+ ngx_js_module was configured
老规矩附上 我编译的musl版本.gz 和 Nginx1.27.gz
如果出现这些问题请下载这个:最新(0.8.5 + 1.27.0)静态编译版本.gz
/usr/local/osgi/bin # ./nginx -v
Error relocating /lib/libcrypto.so.1.1: __xstat: symbol not found
Error relocating /lib/libcrypto.so.1.1: setcontext: symbol not found
Error relocating /lib/libcrypto.so.1.1: makecontext: symbol not found
Error relocating /lib/libcrypto.so.1.1: getcontext: symbol not found
Error relocating /lib/libcrypto.so.1.1: __register_atfork: symbol not found
Error relocating /lib/libcrypto.so.1.1: __fxstat: symbol not found
TypeScript?yes!
但是njs实在是太不完善了,详见我的进阶文章
本文由 zlh 创作,采用 知识共享署名4.0 国际许可协议进行许可。
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。