nginx+lua 实现URL重定向(根据传入的参数条件)

程序版本说明

程序 版本 URL
nginx 1.27.0 https://nginx.org/download/nginx-1.27.0.tar.gz
ngx_devel_kit v0.3.3 https://github.com/simpl/ngx_devel_kit/archive/v0.3.3.tar.gz
luajit v2.1 https://github.com/openresty/luajit2/archive/refs/tags/v2.1-20240626.tar.gz
lua-nginx-module v0.10.26 https://github.com/openresty/lua-nginx-module/archive/v0.10.26.tar.gz
lua-resty-core v0.1.28 https://github.com/openresty/lua-resty-core/archive/refs/tags/v0.1.28.tar.gz
lua-resty-lrucache v0.12 https://github.com/openresty/lua-resty-lrucache/archive/refs/tags/v0.12.tar.gz
lua-resty-http v0.17.2 https://github.com/ledgetech/lua-resty-http/archive/refs/tags/v0.17.2.tar.gz
lua-cjson 2.1.0.9 https://github.com/openresty/lua-cjson/archive/refs/tags/2.1.0.9.tar.gz

安装Lua

从https://github.com/openresty/luajit2下载安装

# git clone https://github.com/openresty/luajit2.git
cd /root/soft
wget https://github.com/openresty/luajit2/archive/refs/tags/v2.1-20240626.tar.gz
tar -xzvf v2.1-20240626.tar.gz
cd luajit2-2.1-20240626
make && make install
ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

添加环境变量

vim /etc/profile
#最后两行添加如下内容:
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
下载解压ngx_devel_kit
cd /root/soft
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.3.tar.gz
tar -xzvf v0.3.3.tar.gz

下载解压lua-nginx-module
cd /root/soft
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.26.tar.gz
tar -xzvf v0.10.26.tar.gz
# lua-nginx-module-0.10.16 以后都需要 lua-resty-core和lua-resty-lrucache**
wget https://github.com/openresty/lua-resty-core/archive/refs/tags/v0.1.28.tar.gz
tar -xzvf v0.1.28.tar.gz
cd lua-resty-core-0.1.28
make && make install LUA_LIB_DIR=/usr/local/share/lua/5.1

wget https://github.com/openresty/lua-resty-lrucache/archive/refs/tags/v0.12.tar.gz
tar -xzvf v0.12.tar.gz
cd lua-resty-lrucache-0.12

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-15 07:40:03       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-15 07:40:03       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-15 07:40:03       57 阅读
  4. Python语言-面向对象

    2024-07-15 07:40:03       68 阅读

热门阅读

  1. Vue2-案例tab切换栏高亮

    2024-07-15 07:40:03       25 阅读
  2. 项目管理·沟通管理

    2024-07-15 07:40:03       26 阅读
  3. CentOS Stream 卸载 Podman 并安装 Docker 的方法

    2024-07-15 07:40:03       21 阅读
  4. 关于 LayoutInflater.inflate 的取值结论

    2024-07-15 07:40:03       21 阅读
  5. Zynq7000系列FPGA中的DMA控制器的编程限制

    2024-07-15 07:40:03       19 阅读