centos
1.openresty
yum install openresty
yum install openresty-resty
yum install openresty-doc
2.lua 5.2
3.luaiconv
- wget https:
- tar -xvf lua-iconv-7.tar.gz
- cd lua-iconv-7
- gcc -O2 -fPIC -I/usr/include/lua5.1 -c luaiconv.c -o luaiconv.o -I/usr/include
- gcc -shared -o iconv.so -L/usr/local/lib luaiconv.o -L/usr/lib
- cp iconv.so /my-pet-project/third-party/
4 nginx.conf
lua_package_cpath 'third-party/?.so;;';
5.
local iconv = require("iconv")
local togbk = iconv.new("gbk", "utf-8")
local str, err = togbk:iconv(res.body)
ngx.say(str)
6 error
2016/09/20 12:48:03 [error] 88741#88741: *103 lua entry thread aborted: runtime error: error loading module 'iconv' from file 'third-party/iconv.so':
third-party/iconv.so: undefined symbol: luaL_setfuncs
stack traceback: