why return HTTP 500 when use the require "resty.memcached" in HttpLuaModule module?
agentzh at gmail.com
Sat Jun 16 08:22:35 UTC 2012
On Sat, Jun 16, 2012 at 2:44 PM, Xiangong Yang <monitor.xoyo at gmail.com> wrote:
> # set search paths for pure Lua external libraries (';;' is the default
> # set search paths for Lua external libraries written in C (can also use
This is really a FAQ for Lua beginners, not specific to ngx_lua. In
short, you should really use "/usr/local/lib/lua/?.lua" in your
lua_package_path here instead of "/usr/local/lib/lua/resty/?.lua"
because you're requiring "resty.memcached" below in your Lua code,
which will make the Lua VM substitute the "?" part in your search path
with the string "resty/memcached" rather than "memcached".
I suggest you just use the ngx_openresty bundle directly. It has all
the components and search paths properly pre-configured for you :) But
there's nothing that can stop you from doing all these configurations
> the require "resty.memcached" code leads the nginx retrun HTTP 500 (500
> Internal Server Error)
When you see 500 or empty reply from the server, you should always
check out your nginx's error.log file for detailed error messages. If
you do, you'll see from error.log that lua fails to find
resty.memcached in your search paths.
BTW, you're recommended to use LuaJIT 2.0 instead of the standard Lua
5.1 interpreter with ngx_lua, see:
Because LuaJIT 2.0 is usually much faster and smaller (in terms of
memory footprint) and has many less limitations in terms of
functionalities as compared to the standard Lua 5.1 interpreter.
More information about the nginx