Follow instructions here
rm -rf /tmp/nginx
mkdir -p /tmp/nginx
cd /tmp/nginx
nginx -v
NGINX_VERSION=$(nginx -v 2>&1 | awk -F/ '{print $2}')
wget https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
# Downloading Lua
wget https://github.com/openresty/luajit2/archive/v2.1-20200102.tar.gz
# Downloading Nginx development kit
wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1.tar.gz
# Downloading Nginx Lua Module
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.15.tar.gz
# Downloading Resty Core
wget https://github.com/openresty/lua-resty-core/archive/v0.1.17.tar.gz
# Downloading Resty LRU Cache
wget https://github.com/openresty/lua-resty-lrucache/archive/v0.09.tar.gz
find . -type f -name '*.tar.gz' -exec tar -xzf {} \;
cd /tmp/nginx
# Change directory to the lua language library. Not the one above
cd luajit*
make & make install
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
cd /tmp/nginx/lua-resty-core-0.1.17
make install
cd /tmp/nginx/lua-resty-lrucache-0.09
make install
cd ../nginx-1.17.6/
NGINX_CONFIGURE_ARGUMENTS=$(echo $(nginx -V 2>&1) | sed -nr '/configure arguments:/ s/.*configure arguments:([^"]+).*/\1/p')
eval "./configure --with-ld-opt="-Wl,-rpath,/usr/local/lib" --add-dynamic-module=../ngx_devel_kit-0.3.1 --add-dynamic-module=../lua-nginx-module-0.10.15 $NGINX_CONFIGURE_ARGUMENTS"
make modules
# The target path can be found using `nginx -V`
mv objs/*.so /usr/lib64/nginx/modules
# Create symbolic link to modules
ln -s /usr/lib64/nginx/modules /etc/nginx/modules
# Note my prefix is /etc/nginx. This can be obtained using `nginx -V`
mkdir -p /etc/nginx/modules-enabled/
echo -e "load_module modules/ndk_http_module.so;\nload_module modules/ngx_http_lua_module.so;" > /etc/nginx/modules-enabled/lua.conf
include /etc/nginx/modules-enabled/*.conf;
# Source: OpenResty Core Readme
# you do NOT need to configure the following line when you
# are using the OpenResty bundle 1.4.3.9+.
lua_package_path "/usr/local/lib/lua/?.lua;;";
init_by_lua_block {
require "resty.core"
collectgarbage("collect") -- just to collect any garbage
}
systemctl restart nginx
Good luck
Building Nginx with Lua
Installing Nginx on CentOS 7
Dynamic Modules
Dynamic Modules Compiling
Compatibility Issue
OpenResty Core not found Issue
Replace Chars after string in Bash