nginx教程七,基于OpenResty用lua语言实现简单服务

一、搭建openresty环境

参考nginx教程四

二、编写lua语言实现简单服务

1. 修改openresty中nginx.conf文件,在server模块下添加location

        location /lua {
            default_type text/html;
            content_by_lua 'ngx.say("User-Agent: ", ngx.req.get_headers()["User-Agent"])';
        } 

2.启动openresty,访问

3. 实践中,可以借助openresty提供的lua API操作数据库或Redis等

原文地址:https://www.cnblogs.com/hujiapeng/p/14407810.html