[openresty] hello world
2016-02-04 14:53
316 查看
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;
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 详解Lua中的表的概念及其相关操作方法
- Lua编程示例(二):面向对象、metatable对表进行扩展
- 把Lua编译进nginx步骤方法
- Lua脚本自动生成APK包
- Lua中的元表(metatable)、元方法(metamethod)详解
- Lua中的metatable介绍
- Lua中ipair和pair的区别