2018-12-29 OpenResty 用 Lua 语言实现简单服务

1、下载openresty的源码包

下载地址:http://openresty.org/cn/download.html

2、编译安装openresty

tar -xvf openresty-1.13.6.2.tar.gz
cd openresty-1.13.6.2/
./configure --prefix=/data/openresty
gmake&&gmake install
/data/openresty/nginx/sbin/nginx   #启动服务

3、修改配置文件

vim nginx.conf
 location /lua {
            default_type text/html;
            content_by_lua 'ngx.say("User-Agent: ", ngx.req.get_headers()["User-Agent"])';  #当访问的uri为lua时就用lua代码去执行,返回给客户端浏览器的类型
        }
/data/openresty/nginx/sbin/nginx -s reload

你可能感兴趣的:(2018-12-29 OpenResty 用 Lua 语言实现简单服务)