Lua > OpenResty Lua Module

Lua > OpenResty Lua Module

参考 https://www.bilibili.com/video/BV1k54y1z7L5/

bash 复制代码
mkdir hello
cd hello
mkdir conf logs lua
vim lua/hello.lua
vim conf/nginx.conf

lua/hello.lua

lua 复制代码
local _M = {}

function _M.greet(name)
    ngx.say("Hello ", name)
end

return _M

conf/nginx.conf

conf 复制代码
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    lua_package_path "$prefix/lua/?.lua;;";  
    server {
        listen 8888 reuseport;
        
        location / {
            default_type text/plain;
            content_by_lua_block {
                local hello = require "hello"
                hello.greet("World")
            }
        }
    }
}
bash 复制代码
tree

.

├── conf

│ └── nginx.conf

└── logs

bash 复制代码
nginx -p ./ -t
nginx -p ./
ps aux | grep nginx
curl 'http://127.0.0.1:8888'

Hello World

相关推荐
气概1 天前
法奥机器人学习使用
学习·junit·机器人
恋爱绝缘体12 天前
2020重学C++重构你的C++知识体系
java·开发语言·c++·算法·junit
code_lfh3 天前
Spring Boot测试类的使用参考
java·spring boot·junit
亓才孓4 天前
JUnit--Before,After,Test标签
java·junit·log4j
_200_5 天前
Lua 流程控制
开发语言·junit·lua
姓蔡小朋友7 天前
LUA脚本
开发语言·junit·lua
indexsunny9 天前
互联网大厂Java面试实战:Spring Boot、微服务与Kafka在电商场景中的应用
java·spring boot·redis·junit·kafka·mockito·microservices
_200_11 天前
Lua 运算符
开发语言·junit·lua
_200_11 天前
Lua 基本数据类型
开发语言·junit·lua
㳺三才人子12 天前
初探 Spring Framework OncePerRequestFilter
spring boot·spring·junit