谢谢,我觉得整合一起编译方便我部署 :),而且参考了人家整合
lua-iconv 的方法,可以了。
还有个lua_cjson 的decode问题要请教:
location /t {
charset utf-8;
content_by_lua '
local cjson = require("cjson")
local json_text = "[ true, { "foo": "bar" } ]"
local lua_table = cjson.decode(json_text)
ngx.say(lua_table)
';
}
以上代码测试时出现错误:
[error] 18636#0: *2 lua entry thread aborted: runtime error: [string "content_by_lua"]:3: attempt to call global 'foo' (a nil value)
stack traceback:
coroutine 0:
[string "content_by_lua"]: in function <[string "content_by_lua"]:1>,
On Tuesday, December 25, 2012 12:31:12 PM UTC+8, agentzh wrote:
Hello!On Mon, Dec 24, 2012 at 7:23 PM, Bill Zhu <bill...@gmail.com> wrote:
> 比如:
>
> lua-cjson最新版是2.1.0,支持json.decode:
>
> http://www.kyne.com.au/~mark/software/lua-cjson.php
>
> 我想用cosmo,需要 Luajit-LPEG:
>
> https://github.com/LuaDist/cosmo/blob/master/doc/cosmo.md
> https://github.com/sacek/Luajit-LPEG
> http://www.inf.puc-rio.br/~roberto/lpeg/
>
> 我看了 https://github.com/agentzh/ngx_openresty,但对perl不熟.
>
你需要使用的第三方 Lua 库可以安装到你系统的任意位置,只需在 nginx.conf 中恰当地配置 lua_pakcage_path 或者
lua_package_cpath 指令即可:
http://wiki.nginx.org/HttpLuaModule#lua_package_path
http://wiki.nginx.org/HttpLuaModule#lua_package_cpath
或者把你的 Lua 库安装到默认可见的 Lua 库搜索路径下。
Best regards,
-agentzh