Home >Backend Development >PHP Tutorial >[openresty] hello world

[openresty] hello world

WBOY
WBOYOriginal
2016-07-29 09:09:501102browse

[openresty] hello world

openresty software deployment

Not to mention, it is similar to nginx.

content_by_lua instruction

You can use the content_by_lua instruction to include a piece of lua code into nginx for execution. For example, the simplest call ngx.say below is to output Hello world.

<code>    location / {
            default_type <span>text</span>/html;
            content_by_lua '
                ngx.<span>say</span>(<span>"<p>hello, world</p>"</span>)
            ';
        }
</code>

Longer code is suitable to use rewrite_by_lua_file

followed by a path path

<code>    location / {    
            content_by_lua_file lua/hello.lua;
        }

[root<span>@test</span> nginx]<span># cat lua/hello.lua</span>
ngx.<span>say</span>(<span>"<p>hello, world!!! hey man</p>"</span>)        </code>

lua_code_cache

By default nginx has a layer of cache for the Lua code segment, which improves efficiency, but this also requires us to modify Lua every time. Reload nginx can take effect. At this time, we can turn off the cache, it will take effect in real time, and then turn it on after debugging is completed.

<code>lua_code_cache <span>off</span>;</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces [openresty] hello world, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn