nginx安装lua模块

安装Nginx1.6.2
升级Nginx1.8.1
Nginx下载模块
lua官网下载地址
LuaJIT下载页面
在这里插入图片描述
在这里插入图片描述
lua安装

wget  http://www.lua.org/ftp/lua-5.3.5.tar.gz
tar -xf lua-5.3.5.tar.gz
cd lua-5.3.4/
make linux test
make install

在这里插入图片描述
在这里插入图片描述

wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar -xf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5/
make
make install PREFIX=/usr/local/LuaJIT

在这里插入图片描述
NDK(nginx development kit)模块是一个拓展nginx服务器核心功能的模块,第三方模块开发可以基于它来快速实现。 NDK提供函数和宏处理一些基本任务,减轻第三方模块开发的代码量。
下载ngx_devel_kit模块
下载lua-nginx-module模块

wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.15.tar.gz
cd /usr/local/nginx/module
tar -xf v0.3.1.tar.gz
tar -xf v0.10.15.tar.gz

添加设置luaJit的环境变量(如果这一步设置错误会报错:/configure: error: ngx_http_lua_module requires the Lua library.)
在这里插入图片描述

export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0						#路径是上面luajit实际安装路径,路径错误安装lua模块时会报错很早不到luajit库
export LUAJIT_LIB=/usr/local/LuaJIT/lib

预编译:
通过nginx -V获取之前预编译参数,并增加 --add-module参数

yum -y install lua-devel
cd /root/nginx-1.8.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-threads --user=www --group=www --add-module=/usr/local/nginx/module/echo-nginx-module-0.61 --add-module=/usr/local/nginx/module/lua-ssl-nginx-module-0.01rc3 --add-module=/usr/local/nginx/module/xss-nginx-module-0.06 --add-module=/usr/local/nginx/module/nginx-eval-module-2016.06.10 --add-module=/usr/local/nginx/module/ngx_devel_kit-0.3.1 --add-module=/usr/local/nginx/module/lua-nginx-module-0.10.15
# 编译器
./configure 
> --prefix=/usr/local/nginx 
> --with-http_ssl_module 
> --with-http_realip_module 
> --with-http_addition_module 
> --with-http_sub_module 
> --with-http_dav_module 
> --with-http_flv_module 
> --with-http_mp4_module 
> --with-http_gunzip_module 
> --with-http_gzip_static_module 
> --with-http_auth_request_module 
> --with-http_random_index_module 
> --with-http_secure_link_module 
> --with-http_degradation_module 
> --with-http_stub_status_module 
> --with-mail --with-mail_ssl_module 
> --with-threads 
> --user=www 
> --group=www 
> --add-module=/usr/local/nginx/module/echo-nginx-module-0.61 
> --add-module=/usr/local/nginx/module/lua-ssl-nginx-module-0.01rc3 
> --add-module=/usr/local/nginx/module/xss-nginx-module-0.06 
> --add-module=/usr/local/nginx/module/nginx-eval-module-2016.06.10 
> --add-module=/usr/local/nginx/module/ngx_devel_kit-0.3.1 
> --add-module=/usr/local/nginx/module/lua-nginx-module-0.10.15
make && make install

在这里插入图片描述

cd objs/
cp /usr/local/nginx/sbin/nginx /usr/local/sbin/nginx.bak
cp nginx /usr/local/nginx/sbin/nginx

在这里插入图片描述

vim /etc/ld.so.conf.d/usr_local_lib.conf
/usr/loca/lib
/usr/local/LuaJIT/lib
ldconfig
vim /usr/local/nginx/conf/nginx.conf

http{
    ...
        
       lua_package_cpath '/usr/local/LuaJIT/lib/lua/5.1/?.so;;';
       lua_package_path '/usr/local/LuaJIT/share/luajit-2.0.5/resty/?.lua;;'; 
        
    ...
    server{
        ...
    }
}
nginx -s reload
nginx -V
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值