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

相关推荐
Lbwnb丶21 小时前
JUnit 4 + Spring Boot 测试依赖
数据库·spring boot·junit
java搬砖工-苤-初心不变15 天前
基于 lua_shared_dict 的本地内存限流实现
开发语言·junit·lua
不要再敲了17 天前
掌握单元测试的利器:JUnit 注解从入门到精通
junit·单元测试
山楂树下懒猴子20 天前
ChatAI项目-ChatGPT-SDK组件工程
人工智能·chatgpt·junit·https·log4j·intellij-idea·mybatis
一线灵23 天前
跨平台游戏引擎 Axmol-2.8.1 发布
junit·游戏引擎
奔跑吧邓邓子24 天前
【Java实战㉖】深入Java单元测试:JUnit 5实战指南
java·junit·单元测试·实战·junit5
A尘埃1 个月前
缓存工具服务(封装缓存击穿+缓存穿透+缓存雪崩)
缓存·junit·缓存工具类封装
夜猫逐梦1 个月前
【lua】Lua 入门教程:从环境搭建到基础编程
junit
斯普信专业组1 个月前
Fluent Bit系列:字符集转码测试(上)
junit·fluent bit