openresty / lua-nginx-module

Embed the Power of Lua into NGINX HTTP servers
https://openresty.org/
11.34k stars 2.04k forks source link

Nginx installation documentation doesnt work. #1829

Open dlannan-fmad opened 4 years ago

dlannan-fmad commented 4 years ago

github checkout of lua-nginx-modile nginix version 1.19.0 openresty luajit2-2.1-20201027

I followed the instructions to install with nginx and I get this:

nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)
nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
        no field package.preload['resty.core']
        no file './resty/core.lua'
        no file '/usr/local/share/luajit-2.1.0-beta3/resty/core.lua'
        no file '/usr/local/share/lua/5.1/resty/core.lua'
        no file '/usr/local/share/lua/5.1/resty/core/init.lua'
        no file './resty/core.so'
        no file '/usr/local/lib/lua/5.1/resty/core.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty.so'
        no file '/usr/local/lib/lua/5.1/resty.so'
        no file '/usr/local/lib/lua/5.1/loadall.so') in /opt/fmadio/www/conf/nginx_http.conf:142

The error states to use the openresty luajit - but it is. I followed the instructions to do so. And there is no other luajit installed on the system. I have tried various different tweaks, but I cannot seem to get this to work. It looks like resty.core is required to use this module in nginx. Is that the case? I do not wish to add openresty (its far too big for our implementation - we cant afford large changes in files and structure). If openresty is now required I'll add my own luajit module.

Any help would be greatly appreciated.

dlannan-fmad commented 4 years ago

I think it must be related to our platform. We are using tiny core linux, with many customizations. Going to check environment variables and paths. Im still not quite understanding why the package search path is looking in '/usr/local/share/luajit-2.1.0-beta3/resty/core.lua' when the recommended luajit is 2-2.1 ? Could this be an issue?

dlannan-fmad commented 4 years ago

After many attempts, it doesnt appear that the installation procedure for nginx works. There is always a dependency to load resty.core when exectued. image We do not want to use openresty - can someone confirm if this module works as a standalone nginx module or not?

I should also note, all the tests pass fine during the build process. So this seems a little odd.

dlannan-fmad commented 4 years ago

Ok. More investigation into this build process, and it looks like there is a dependency on the lua resty core repo: https://github.com/openresty/lua-resty-core Which means the install documents will not allow building of the module with the installation of the above repo.

Quick question: Is there a bundle that can be used with the nginx module? Rather than a bunch of lua script spread across various directories?

dlannan-fmad commented 4 years ago

I have found a solution, and it seems to work (obviously resty.core features will not work). Comment out lines 3996-4002 here: https://github.com/openresty/lua-nginx-module/blob/7105adaa523adedec80f0aaa13388b88d08988f8/src/ngx_http_lua_util.c#L3996-L4002 And comment out: https://github.com/openresty/lua-nginx-module/blob/7105adaa523adedec80f0aaa13388b88d08988f8/src/ngx_http_lua_util.c#L3924

This will allow you to build this module without the need of installing the full openresty system.

Firegarden commented 3 years ago

Amazing how many people have this problem. I believe the solution is simple - you need update your nginx.conf to include the lua package path as follows

lua_package_path "/usr/local/lib/lua/?.lua;;";

dlannan commented 3 years ago

Amazing how many people have this problem. I believe the solution is simple - you need update your nginx.conf to include the lua package path as follows

lua_package_path "/usr/local/lib/lua/?.lua;;";

This wont help with building without resty.core. Which is what is mentioned in the comment - no openresty, just the lua module.

Firegarden commented 3 years ago

@dlannan sorry I did not read the thread. Thank you for your correction.

I am a little confused if you wish to avoid OPENRESTY or avoid RESTY CORE the reason I ask is because I don't use openresty rather I just download resty-core eg. sudo wget https://github.com/openresty/lua-resty-core/archive/v${LUA_RESTY_CORE}.tar.gz

this is significantly less than having to build the full openresty

note I did find I need to now download lua-resty-lrucache as well to get it all working.

so in summary in my build I use the following and it works fine

dlannan commented 3 years ago

No probs. Our use case is a little erm.. specific :) There are a couple of modules, and I have developed some addon modules for doing quite bespoke interactions with lua all embedded into static libs (hence the need to hand build most of this). We dont run any shared libs.