安装 nginx-lua module

3 篇文章 0 订阅

遇到个 openssl 的坑 记录一下

系统环境: 通用

1 - 先下载安装 LuaJIT-2.0.4.tar.gz
wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz

tar xzvf LuaJIT-2.0.4.tar.gz

cd LuaJIT-2.0.4

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
2.下载解压 ngx_devel_kit
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz

tar -xzvf v0.3.0.tar.gz
3.下载解压 lua-nginx-module
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.8.tar.gz

tar -xzvf v0.10.8.tar.gz
4 安装 nginx
wget -c http://nginx.org/download/nginx-1.10.3.tar.gz
tar xzvf nginx-1.10.3.tar.gz
cd nginx-1.10.3

如果已经安装了nginx 可以 nginx -V (大V) 查看编译选项,只要加上 ngx_devel_kitlua-nginx-module-0.10.10 就可以了

//conf 编译安装 这里扩展包和上面版本不一致自己去找下 ,或者用你自己喜欢的也可以,但是openssl 要用1.0.2的 ,这就是坑点

./configure  --prefix=/etc/nginx --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.39 --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --conf-path=/etc/nginx/nginx.conf --http-uwsgi-temp-path=/etc/nginx/uwsgi_params --http-fastcgi-temp-path=/etc/nginx/fastcgi_params --http-scgi-temp-path=/etc/nginx/scgi_params --with-http_v2_module --with-http_stub_status_module --with-http_gzip_static_module --with-ipv6 --with-openssl=/usr/local/src/openssl-1.0.2m    --add-module=/usr/local/src/lua-nginx-module-0.10.10   --add-module=/usr/local/src/ngx_devel_kit-0.3.0

make  && make install 

好了,坑来了,一直报下面这个错误:

/usr/local/src/nginx-1.10.3/modules/lua-nginx-module/src/ngx_http_lua_module.c: In functionngx_http_lua_merge_srv_conf’:
/usr/local/src/nginx-1.10.3/modules/lua-nginx-module/src/ngx_http_lua_module.c:1022:37: error: passing argument 2 of ‘SSL_CTX_sess_set_get_cb’ from incompatible pointer type [-Werror]
                                     ngx_http_lua_ssl_sess_fetch_handler);
                                     ^
In file included from src/event/ngx_event_openssl.h:15:0,
                 from src/core/ngx_core.h:83,
                 from /usr/local/src/nginx-1.10.3/modules/lua-nginx-module/src/ddebug.h:13,
                 from /usr/local/src/nginx-1.10.3/modules/lua-nginx-module/src/ngx_http_lua_module.c:11:
/usr/include/openssl/ssl.h:637:6: note: expected ‘struct SSL_SESSION * (*)(struct ssl_st *, const unsigned char *, int,  int *)’ but argument is of type ‘struct SSL_SESSION * (*)(struct SSL *, u_char *, int,  int *)’
 void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
      ^
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/src/ngx_http_lua_module.o] 错误 1
make[1]:正在离开目录 `/usr/local/src/nginx-1.10.3'
make: *** [build] 错误 2
错误原因:

nginx-lua-moduleopenssl 1.0.1 冲突,将 openssl 换成 1.0.2 即可

测试:

nginx.conf或者你的 vhost.conf 中 server{} 中添加

location /hello {
            default_type 'text/plain';
            content_by_lua 'ngx.say("hello, lua")';
        }

访问 xxx/hello 提示: hello, lua !

参考博客:安装nginx-lua扩展

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值