The Openresty server uses the lua script to write a simple Hello World instance.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.