From 4a7ac04665c8b8df1c9ed257fac972e2d7a548a4 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Sat, 23 Mar 2024 03:20:55 -0400 Subject: [PATCH] add openresty --- .gitmodules | 12 ++++++++++++ README.md | 13 ++++++++++++- build | 25 +++++++++++++++++++++++++ install | 3 +++ sources/lua-resty-core | 1 + sources/lua-resty-lrucache | 1 + sources/luajit2 | 1 + sources/modules/lua-nginx-module | 1 + 8 files changed, 56 insertions(+), 1 deletion(-) create mode 160000 sources/lua-resty-core create mode 160000 sources/lua-resty-lrucache create mode 160000 sources/luajit2 create mode 160000 sources/modules/lua-nginx-module diff --git a/.gitmodules b/.gitmodules index a281178..3c69447 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,15 @@ [submodule "sources/modules/ngx-fancyindex"] path = sources/modules/ngx-fancyindex url = https://github.com/aperezdc/ngx-fancyindex +[submodule "sources/modules/lua-nginx-module"] + path = sources/modules/lua-nginx-module + url = https://github.com/openresty/lua-nginx-module +[submodule "sources/lua-resty-core"] + path = sources/lua-resty-core + url = https://github.com/openresty/lua-resty-core +[submodule "sources/lua-resty-lrucache"] + path = sources/lua-resty-lrucache + url = https://github.com/openresty/lua-resty-lrucache +[submodule "sources/luajit2"] + path = sources/luajit2 + url = https://github.com/openresty/luajit2 diff --git a/README.md b/README.md index 991b447..4895bef 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # `nginx-cn` -Our build of NGINX we use. +Our build of NGINX we use. Precompiled with OpenResty core and several other useful modules. + +# Build/installaction instructions + +```bash +$ git clone --recursive https://git.computernewb.com/nginx-cn +$ cd nginx-cn +$ ./build +# ./install +# ... (copy the base config from sources/nginx/conf into /opt/nginx/etc/nginx) +# profit? +``` diff --git a/build b/build index 9a72e65..b8b31fa 100755 --- a/build +++ b/build @@ -1,9 +1,13 @@ #!/bin/bash +# installation prefix. unfortunately we have to vendor +# certains dependencies (luajit) so this /opt path is +# (probably) going to unfortunately stick. PREFIX="/opt/nginx" TOP="$(pwd)" +# clean Nginx sources pushd sources/nginx/ echo "cleaning nginx sources" git clean -dxf @@ -56,6 +60,7 @@ BASE_CONFIGURE_FLAGS=( # Add modules into the build we use --add-module=$TOP/sources/modules/nginx-module-vts --add-module=$TOP/sources/modules/ngx-fancyindex + --add-module=$TOP/sources/modules/lua-nginx-module # --add-module=$TOP/sources/modules/nginx-rtmp-module # --add-module=$TOP/modules/nginx-dav-ext-module ) @@ -66,8 +71,28 @@ CFLAGS="-O3 -march=native -mtune=native -pipe -flto=thin -pipe" CC="clang" \ ./configure popd +# build and install luajit and the resty lua libraries into prefix +pushd $TOP/sources/luajit2 + git clean -dxf + make PREFIX=$PREFIX -j49 + sudo make PREFIX=$PREFIX install +popd + +pushd $TOP/sources/lua-resty-core + sudo make install PREFIX=$PREFIX +popd + +pushd $TOP/sources/lua-resty-lrucache + sudo make install PREFIX=$PREFIX +popd + pushd $TOP/sources/nginx +# needed for lua-nginx-module +export LUAJIT_INC="$PREFIX/include/luajit-2.1" +export LUAJIT_LIB="$PREFIX/nginx/lib" + +# TODO: see ./install for --sbin-path ./auto/configure \ --prefix=$PREFIX/etc/nginx \ --conf-path=$PREFIX/etc/nginx/nginx.conf \ diff --git a/install b/install index 8de2ab2..cb4f4a2 100755 --- a/install +++ b/install @@ -8,11 +8,14 @@ TOP="$(pwd)" exit 1 } +# N.B: We do not use nginx's `make install` because it's very very bad +# and it overwrites $PREFIX/etc unconditionally. It's bad. I don't like it. pushd $TOP/sources sudo systemctl stop nginx-cn # strip binary of unneeded fluff (saving the original) cp nginx/objs/nginx nginx/objs/nginx.unstripped strip nginx/objs/nginx + # FIXME: /opt/nginx/bin would probably be less annoying tbh.. sudo cp nginx/objs/nginx /opt/nginx/usr/bin sudo systemctl start nginx-cn #sudo make install diff --git a/sources/lua-resty-core b/sources/lua-resty-core new file mode 160000 index 0000000..fc9e2ba --- /dev/null +++ b/sources/lua-resty-core @@ -0,0 +1 @@ +Subproject commit fc9e2ba34498fabc607754afa49b7721b47e7b70 diff --git a/sources/lua-resty-lrucache b/sources/lua-resty-lrucache new file mode 160000 index 0000000..82b5ab4 --- /dev/null +++ b/sources/lua-resty-lrucache @@ -0,0 +1 @@ +Subproject commit 82b5ab467aa46495db09499725eb87d4a7c1bc1c diff --git a/sources/luajit2 b/sources/luajit2 new file mode 160000 index 0000000..15f58c9 --- /dev/null +++ b/sources/luajit2 @@ -0,0 +1 @@ +Subproject commit 15f58c9648ee40a3fb6617e22e2f3fdff80d66b8 diff --git a/sources/modules/lua-nginx-module b/sources/modules/lua-nginx-module new file mode 160000 index 0000000..45db94a --- /dev/null +++ b/sources/modules/lua-nginx-module @@ -0,0 +1 @@ +Subproject commit 45db94a3440a12165b8d64495a4b5dd78678214f