- 时间:2020-08-07 02:31 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Openresty服务器使用lua脚本写的Hello World简单实例
Openresty提供了丰富的接口和变量给Lua,开发者可以充分利用Lua语言特性和这些接口进行高效率开发。万事开头难,但是对于编程来说能写出Hello world就已经算是成功一半了。
1、安装openresty
2、配置nginx
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /lua {
default_type text/plain;
content_by_lua_file /opt/lua/bin/test.lua;
}
........
}
3、新建 /opt/lua/bin/test.lua
local welcome = 'Hello World'
ngx.say(welcome)
4、访问即可
[img]http://files.jb51.net/file_images/article/201504/201542092151487.jpg?201532092220[/img]