Nginx1.24.0升级

记录一次Nginx升级经历,升级到1.24.0版本,引用了lua模块


1、版本准备

nginx 1.24.0

lua-nginx-module 0.10.23

ngx_devel_kit 0.3.1rc1

pcre 8.45

openssl 1.1.1a

LuaJIT 2.1.0-beta3

上述版本组合是经过无数次尝试得到,可编译通过

2、编译

2.1 编译环境准备

系统版本:Red Hat Enterprise Linux Server release 7.2 (Maipo)

先安装LuaJIT 2.1.0-beta3

进入LuaJIT的源码目录,make install

export LUAJIT_INC=/usr/local/include/luajit-2.1/

export LUAJIT_LIB=/usr/local/lib/

2.2 configure & make

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=../openssl-1.1.1a --add-module=../ngx_devel_kit-0.3.1rc1 --add-module=../lua-nginx-module-0.10.23 --with-pcre=../pcre-8.45/ --with-pcre-jit

make -j8

make install

3.运行

3.1、运行时,可能报错1:

./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

解决方法:

这里LUAJIT_LIB安装到了/usr/local/lib,有些系统so的加载路径可能没有这个目录,在/etc/ld.so.conf.d/目录增加一个配置文件,然后执行ldconfig即可

例如,新建/etc/ld.so.conf.d/userlocal.conf文件,文件内容:

/usr/local/lib/

3.2、运行时,可能报错2:

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模块,重新configure,去掉lua模块引用。


如果需要使用lua模块,目前0.10.23版本未有对应的lua-resty-core模块版本,从http://openresty.org/en/获取的最新支持到的版本为nginx1.21.4、ngx_lua-0.10.21


PS:尝试过硬装lua-resty-core-0.1.23、 lua-resty-lrucache-0.11 ,运行时会提示版本限制

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: /usr/local/share/lua/5.1/resty/core/base.lua:24: ngx_http_lua_module 0.10.21 required) in /usr/local/nginx/conf/nginx.conf:609


lua-nginx-modul gitlab上有相关问题的讨论,但针对的是旧版本了,可以跟踪下:

https://github.com/openresty/lua-nginx-module/issues/1533#issuecomment-524082852

https://github.com/openresty/lua-nginx-module/issues/1884

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容