报错信息:

nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from 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 /usr/local/nginx/conf/nginx.conf:222

原因分析:

找不到lualib库和resty模块,默认到/usr/local/lib/ 去找lualib,然而在编译安装OpenResty时lualib库默认放到/usr/local/openresty/lualib
 $ ln -s /usr/local/openresty/lualib /usr/local/lib/lua $ ln -s /usr/local/openresty/lualib/resty /usr/local/lib
如果是之前已配置“ln -s /usr/local/openresty/lualib/resty /usr/local/lib”,本次执行“/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf”仍报上述错误,则删除已有的软连接,重新执行“ln -s /usr/local/openresty/lualib/resty /usr/local/lib”

即:

 # cd /usr/local/lib
 # ls
libluajit-5.1.a  libluajit-5.1.so  libluajit-5.1.so.2  libluajit-5.1.so.2.1.0  lua  pkgconfig  resty
 # rm -rf ./resty
 # ln -s /usr/local/openresty/lualib/resty /usr/local/lib
 # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐