add openresty

This commit is contained in:
Lily Tsuru 2024-03-23 03:20:55 -04:00
parent 92368f1a6b
commit 4a7ac04665
8 changed files with 56 additions and 1 deletions

12
.gitmodules vendored
View file

@ -13,3 +13,15 @@
[submodule "sources/modules/ngx-fancyindex"] [submodule "sources/modules/ngx-fancyindex"]
path = sources/modules/ngx-fancyindex path = sources/modules/ngx-fancyindex
url = https://github.com/aperezdc/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

View file

@ -1,3 +1,14 @@
# `nginx-cn` # `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?
```

25
build
View file

@ -1,9 +1,13 @@
#!/bin/bash #!/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" PREFIX="/opt/nginx"
TOP="$(pwd)" TOP="$(pwd)"
# clean Nginx sources
pushd sources/nginx/ pushd sources/nginx/
echo "cleaning nginx sources" echo "cleaning nginx sources"
git clean -dxf git clean -dxf
@ -56,6 +60,7 @@ BASE_CONFIGURE_FLAGS=(
# Add modules into the build we use # Add modules into the build we use
--add-module=$TOP/sources/modules/nginx-module-vts --add-module=$TOP/sources/modules/nginx-module-vts
--add-module=$TOP/sources/modules/ngx-fancyindex --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/sources/modules/nginx-rtmp-module
# --add-module=$TOP/modules/nginx-dav-ext-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 ./configure
popd 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 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 \ ./auto/configure \
--prefix=$PREFIX/etc/nginx \ --prefix=$PREFIX/etc/nginx \
--conf-path=$PREFIX/etc/nginx/nginx.conf \ --conf-path=$PREFIX/etc/nginx/nginx.conf \

View file

@ -8,11 +8,14 @@ TOP="$(pwd)"
exit 1 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 pushd $TOP/sources
sudo systemctl stop nginx-cn sudo systemctl stop nginx-cn
# strip binary of unneeded fluff (saving the original) # strip binary of unneeded fluff (saving the original)
cp nginx/objs/nginx nginx/objs/nginx.unstripped cp nginx/objs/nginx nginx/objs/nginx.unstripped
strip nginx/objs/nginx strip nginx/objs/nginx
# FIXME: /opt/nginx/bin would probably be less annoying tbh..
sudo cp nginx/objs/nginx /opt/nginx/usr/bin sudo cp nginx/objs/nginx /opt/nginx/usr/bin
sudo systemctl start nginx-cn sudo systemctl start nginx-cn
#sudo make install #sudo make install

@ -0,0 +1 @@
Subproject commit fc9e2ba34498fabc607754afa49b7721b47e7b70

@ -0,0 +1 @@
Subproject commit 82b5ab467aa46495db09499725eb87d4a7c1bc1c

1
sources/luajit2 Submodule

@ -0,0 +1 @@
Subproject commit 15f58c9648ee40a3fb6617e22e2f3fdff80d66b8

@ -0,0 +1 @@
Subproject commit 45db94a3440a12165b8d64495a4b5dd78678214f