Nginx 安装 lua-nginx-module

Nginx 安装 lua-nginx-module,即增加Lua模块

安装依赖

yum install -y gcc g++ gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel

安装LuaJIT

wget -c http://luajit.org/download/LuaJIT-2.0.5.tar.gz  //http://luajit.org/download.html
tar -xzf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make install PREFIX=/usr/local/luajit
# 添加环境变量
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0

ln -s /usr/local/luajit/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2  #不增加这行,nginx启动会报错

http://luajit.org/download.html 下载的luajit来安装Nginx,启动时报错如下

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)

先卸载原有luajit,然后从 https://github.com/openresty/luajit2https://github.com/openresty/luajit2/releases 下载

rm -rf /usr/local/luajit
git clone https://github.com/openresty/luajit2
make && make install
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1

ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2  #不增加这行,nginx启动会报错

安装Nginx

mkdir -p /opt/modules
cd /opt/modules

wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -xzf v0.3.0.tar.gz

wget https://github.com/openresty/lua-nginx-module/archive/v0.10.14.tar.gz
tar -xzf v0.10.14.tar.gz
wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar -xzf nginx-1.16.0.tar.gz
cd nginx-1.16.0

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-cc-opt=-O3 --with-stream --add-module=/opt/modules/ngx_devel_kit-0.3.0 --add-module=/opt/modules/lua-nginx-module-0.10.14
make
make install

lua-nginx-module-0.10.15版本报错:

nginx: [error] lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module 'resty.core' not found:
    no field package.preload['resty.core']
    no file '/opt/verynginx/verynginx/lua_script/resty/core.lua'
    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 '/opt/verynginx/verynginx/lua_script/module/resty/core.lua'
    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 '/opt/verynginx/verynginx/lua_script/resty/core.so'
    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 '/opt/verynginx/verynginx/lua_script/resty.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')

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/24/nginx-install-lua-nginx-module/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Nginx 安装 lua-nginx-module
Nginx 安装 lua-nginx-module,即增加Lua模块 安装依赖 yum install -y gcc g++ gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel 安装LuaJIT……
<<上一篇
下一篇>>
文章目录
关闭
目 录