Nginx 安装 lua-nginx-module

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

安装依赖

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

安装LuaJIT

1
2
3
4
5
6
7
8
9
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,启动时报错如下

1
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 下载

1
2
3
4
5
6
7
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

1
2
3
4
5
6
7
8
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
1
2
3
4
5
6
7
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版本报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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')

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :