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

相关推荐
難釋懷10 天前
Nginx外置缓存-redis2-nginx-module
nginx·缓存·junit
山城码农笑松哥13 天前
Redis 8.8 新特性实操笔记:原生数组、INCREX 限流、XNACK 流处理
redis·笔记·junit
難釋懷17 天前
Nginx内存缓存
nginx·缓存·junit
Nuanyt18 天前
SSM 学习记录 第二部分 Spring整合Mybatis&Junit AOP核心概念 Spring事务管理 SpringMVC 请求与响应 Rest风格
java·spring·junit·mybatis·restful
木子杳衫18 天前
Java高级进阶 | 单元测试JUnit + 反射机制实战详解
java·junit·单元测试
烤代码的吐司君18 天前
Lua 脚本
开发语言·junit·lua
文水爱心帮扶20 天前
文明劝导暖街头,青春志愿护通行|文水县爱心帮扶志愿者协会开展暑期交通文明活动
junit
流星白龙23 天前
【Redis】2.Redis重大版本
数据库·redis·junit
测试修炼手册24 天前
[测试技术] TestNG 入门与实战:分组、数据驱动与并行执行
junit·单元测试·log4j