nginx 添加lua
- 
默认情况下Nginx不支持Lua模块,需要安装LuaJIT解释器,并且重新编译Nginx,或者可使用国人开发的openrestry
- 需要的模块:LuaJIT,Ngx_devel和lua-nginx-module
- Luajit官网:https://luajit.org
- 
环境准备yum install -y gcc gcc-c++ make pcre-devel zlib-devel openssl-devel环境准备 
- 
安装LuaJITwget https://luajit.org/download/LuaJIT-2.0.5.tar.gz 
- 
下载、解压lua模块wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz 
 wget https://github.com/openresty/lua-nginx-module/archive/v0.10.21rc2.tar.gz
- 
保留原始模块,用大写V查看已经安装的模块nginx -V nginx version: nginx/1.23.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --with-http_stub_status_module --with-http_ssl_module
- 
路径切换到nginx安装包,这里是安装包路径不是安装路径,重新加载配置./configure --prefix=/安装路径/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-pcre --add-module=/模块解压位置/lua-nginx-module-0.10.21rc2 --add-module=/模块解压位置/ngx_devel_kit-0.3.0 
- 
执行make,千万不要 install
- 
我的错误,这个错误是配置文件错误,手动修改文件error: ‘ngx_http_headers_in_t’ has no member named ‘cookies’ 根据路径指引,找到 cookies修改 
 cookies → cookie
- 
重复 步骤 6
- 
备份cp /安装目录/sbin/nginx nginx.xxx.bak 
- 
配置覆盖cp /安装包目录/objs/nginx /安装目录/sbin/nginx 
- 
试试nginx -V 
- 
重启nginx -s reload 
- 
可能出现的其他错误[root@localhost /]# 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) 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/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 './resty/core.so' no file '/usr/local/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/lib/lua/5.1/loadall.so') in /usr/local/nginx/conf/nginx.conf:31原因是缺少 openresty 或者版本过低 安装或升级最新版本:https://openresty.org/en/download.html cd /usr/local/lib 
 rm -rf ./resty
 ln -s /usr/local/openresty/lualib/resty /usr/local/lib
 nginx 或者/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    这个人很懒,什么也没下留。
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号