用lua写个hello world

94 阅读1分钟

环境说明

● centos 7.9

● openresty 1.21.4.1

安装openresty

参考:juejin.cn/post/723436…

nginx配置

location /lua {
    default_type text/html;
    content_by_lua '
        ngx.say("<p>Hello world</p>")
    ';
}

image.png

重启nginx

# 测试配置文件是否正确
/usr/local/openresty/nginx/sbin/nginx -t
# 重启nginx
/usr/local/openresty/nginx/sbin/nginx -s reload

访问 localhost:80/lua

image.png