nginx+lua配置

wget http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
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.14.tar.gz
wget http://nginx.org/download/nginx-1.20.2.tar.gz


tar zxf v0.3.0.tar.gz
tar zxf LuaJIT-2.1.0-beta3.tar.gz
tar zxf v0.10.14.tar.gz
tar zxf nginx-1.20.2.tar.gz
yum -y  install lua-devel
cd LuaJIT-2.1.0-beta3
make && make install

添加环境变量
vim /etc/profile
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
source /etc/profile


cd ..
cd nginx-1.20.2
./configure --prefix=/opt/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-stream --add-module=/root/soft/nginx/lua/ngx_devel_kit-0.3.0 --add-module=/root/soft/nginx/lua/lua-nginx-module-0.10.14
make && make install

如果是升级,只要执行到make就行
升级
cp /opt/nginx/sbin/nginx{,.old}
cd nginx-1.20.2/objs/
cp -rfp nginx /opt/nginx/sbin/nginx
systemctl restart nginxd (必要重启,不然不生效)

启动时候报错
[root@ip sbin]# ./nginx -V
./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

# vi /etc/ld.so.conf.d/lib.conf
/usr/local/lib
# ldconfig


现在安装lua-cjson
wget https://www.kyne.com.au/~mark/software/download/lua-cjson-2.1.0.tar.gz
tar -zxvf lua-cjson-2.1.0.tar.gz 
cd lua-cjson-2.1.0
# 这里 make 检查报错,需要编辑 Makefile文件
vi Makefile
把 LUA_INCLUDE_DIR =  $(PREFIX)/include/luajit-2.1  这里的路径改成我们上面安装设置的路劲

#这一步之后 make 还是报错:lua_cjson.c:1298:13: error: static declaration
当前路径下
#编辑lua_cjson.c文件,将1298行的 static void luaL_setfun 前面的 static去掉
#到此为止才make 成功
make && make install

#这里参考:https://blog.csdn.net/kunlilove521/article/details/79992579

https://blog.csdn.net/weixin_38251332/article/details/129590762

本站下载以上压缩包
all.tar.zip


标签:

上一篇redis 使用rdb从高版本迁移至低版本
下一篇HTTP状态码(http状态码500)

相关文章