The Openresty server uses the lua script to write a simple Hello World instance.
This article mainly introduces a simple Hello World instance written by the Openresty server using the lua script. OpenResty (also known as ngx_openresty) is a full-featured Web application server. It packages the standard Nginx core, many common third-party modules, and most of their dependencies. For more information, see
Openresty provides rich interfaces and variables for Lua. developers can make full use of the Lua language features and these interfaces for efficient development. Everything is hard to start with, but writing Hello world for programming is half the success.
1. Install openresty
2. Configure nginx
The Code is as follows:
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. Create/opt/lua/bin/test. lua
The Code is as follows:
Local welcome = 'Hello world'
Ngx. say (welcome)
4. Access