[openresty] hello world,openrestyhello
[openresty] hello world,openrestyhello
0.openresty软件部署
不说了,和nginx差不多的。
1.content_by_lua指令
可以用content_by_lua指令将一段lua代码包含到nginx里面去执行,比如下面最简单的调用ngx.say来输出Hello world。
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
2.长一些的代码适合用rewrite_by_lua_file
后面就跟一个path路径
location / {
content_by_lua_file lua/hello.lua;
}
[root@test nginx]# cat lua/hello.lua
ngx.say("<p>hello, world!!! hey man</p>")
3.lua_code_cache
默认nginx对lua代码段有一层缓存,提高了效率,但是这也让我们每次修改完lua以后需要reload nginx才能生效,这时候我们可以关掉cache,实时生效,等调试完毕以后再打开。
lua_code_cache off;
评论暂时关闭