Nginx(OpenResty) 编译安装
OpenResty 将 Nginx、LuaJIT 和常用 Lua 组件打包,适合需要在请求处理流程中运行 Lua 的场景。以下编译当前官方 1.31.9.1。
编译安装
sudo apt update
sudo apt install -y build-essential libpcre2-dev zlib1g-dev libssl-dev curl perl
curl -fLO https://openresty.org/download/openresty-1.31.9.1.tar.gz
tar -xzf openresty-1.31.9.1.tar.gz
cd openresty-1.31.9.1
./configure --prefix=/usr/local/openresty --with-http_ssl_module --with-http_v2_module --with-stream
make -j"$(nproc)"
sudo make install最小 Lua 验证
/usr/local/openresty/bin/resty -e 'print("OpenResty OK")'
/usr/local/openresty/nginx/sbin/nginx -t简单接口
server {
listen 8080;
location /ping {
content_by_lua_block {
ngx.say("pong")
}
}
}然后执行 curl http://127.0.0.1:8080/ping。Linux 生产环境也可使用 官方预编译包。