踩坑日记--CentOS编译安装lua模块

Tsl_Dragon 2020-05-18 09:01:55
安装好Lua模块(LuaJIT-2.0.5)以及在/etc/profile添加完环境变量之后,nginx添加第三方的ngx_devel_kit模块、lua-nginx-module模块编译之后,首次启动nginx(/etc/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf)命令行报如下错误:

报错详情
./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or director


报错原因
/etc/ld.so.conf 此文件记录了编译时使用的动态库的路径,也就是加载so库的路径。默认情况下,编译器只会使用/lib和/usr/lib这两个目录下的库文件,而通常通过源码包进行安装时,如果不
指定--prefix会将库安装在/usr/local目录下,而又没有在文件/etc/ld.so.conf中添加/usr/local/lib这个目录>。这样虽然安装了源码包,但是使用时仍然找不到相关的.so库,就会报错。

解决办法
#手动将动态库libluajit-5.1.so.2加载路径添加到ld.so.conf文件中,命令如下
echo “/usr/local/LuaJIT/lib” >> /etc/ld.so.conf
#将文件/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用
ldconfig

再次运行./nginx -V,发现问题解决
[root@mrpopos sbin]# ./nginx -V
nginx version: nginx/1.14.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_slice_module --with-http_stub_status_module --add-module=../ngx_cache_purge --add-module=/usr/local/src/nginx-upsync-module --add-module=/usr/local/src/ngx_devel_kit --add-module=/usr/local/src/lua-nginx-module


启动nginx(./nginx -c /usr/local/nginx/conf/nginx.conf)又报错,一波刚平一波又起,命令行又报如下错误:

报错详情
[root@mrpopos sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)
nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://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/LuaJIT/share/luajit-2.0.5/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 '/usr/local/LuaJIT/share/lua/5.1/resty/core.lua'
no file '/usr/local/LuaJIT/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/LuaJIT/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/LuaJIT/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so') in /usr/local/nginx/conf/nginx.conf:210


报错原因
编译的时候使用了最新版本的lua-nginx-module模块,使用了最新版就会触发该问题,官方还未修复

解决办法
使用低版本lua-nginx-module-0.10.14方可解决
...全文
576 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧