备注:
大家在进行lapis 开发的时候有些人比较懒直接使用yum 按照luarocks,之后
使用luarocks 安装lapis 一般来说对于linux 64位的环境都会有些问题(包找不到)
1. 错误提示信息
2017/11/18 09:54:09 [error] 21876#0: *1 lua entry thread aborted: runtime error: content_by_lua(nginx.conf.compiled:22):2: module 'lapis' not found:
no field package.preload['lapis']
no file '/usr/local/openresty/site/lualib/lapis.ljbc'
no file '/usr/local/openresty/site/lualib/lapis/init.ljbc'
no file '/usr/local/openresty/lualib/lapis.ljbc'
no file '/usr/local/openresty/lualib/lapis/init.ljbc'
no file '/usr/local/openresty/site/lualib/lapis.lua'
no file '/usr/local/openresty/site/lualib/lapis/init.lua'
no file '/usr/local/openresty/lualib/lapis.lua'
no file '/usr/local/openresty/lualib/lapis/init.lua'
no file './lapis.lua'
no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/lapis.lua'
no file '/usr/local/share/lua/5.1/lapis.lua'
no file '/usr/local/share/lua/5.1/lapis/init.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/lapis.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/lapis/init.lua'
no file '/usr/local/openresty/site/lualib/lapis.so'
no file '/usr/local/openresty/lualib/lapis.so'
no file './lapis.so'
no file '/usr/local/lib/lua/5.1/lapis.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/lapis.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
coroutine 0:
[C]: in function 'require'
以及
2017/11/18 10:19:55 [error] 21973#0: *4 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/lapis/router.lua:3: module 'lpeg' not found:
no field package.preload['lpeg']
no file '/usr/local/openresty/site/lualib/lpeg.ljbc'
no file '/usr/local/openresty/site/lualib/lpeg/init.ljbc'
no file '/usr/local/openresty/lualib/lpeg.ljbc'
no file '/usr/local/openresty/lualib/lpeg/init.ljbc'
no file '/usr/local/openresty/site/lualib/lpeg.lua'
no file '/usr/local/openresty/site/lualib/lpeg/init.lua'
no file '/usr/local/openresty/lualib/lpeg.lua'
no file '/usr/local/openresty/lualib/lpeg/init.lua'
no file './lpeg.lua'
no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/lpeg.lua'
no file '/usr/local/share/lua/5.1/lpeg.lua'
no file '/usr/local/share/lua/5.1/lpeg/init.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/lpeg.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/lpeg/init.lua'
no file '/usr/local/openresty/site/lualib/lpeg.so'
no file '/usr/local/openresty/lualib/lpeg.so'
no file './lpeg.so'
no file '/usr/local/lib/lua/5.1/lpeg.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/lpeg.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
coroutine 0:
[C]: in function 'require'
以及
2. 分析
从上面的错误提示可以看出,主要是包的问题,实际上报是已经安装了,原因64位操作系统,以及luarocks 默认安装包的
位置不是框架查找的地方
我们系统安装的位置:
lapis:
/usr/share/lua/5.1/lapis
lpeg:
/usr/lib64/lua/5.1/lpeg.so
3. 解方法
a. 不用yum 安装而是源码,可控性强,维护简单,参考相关文档
b. nginx.conf 添加 lua_path、lua_cpath 。。。 ,不太喜欢,费事
c. 配置luaroacks lua path 也是一种方法
d. 使用软连接
4. 实际解决(使用d,其他的参考相关文章)
ln -s /usr/lib64/lua /usr/local/lib/lua
ln -s /usr/share/lua/ /usr/local/share/lua
5, 参考文档
https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix#The_default_settings