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

相关推荐
choke23310 小时前
Junit环境配置
junit
晓13137 天前
第五章:Redis多级缓存
junit
我命由我123459 天前
Android 控件 - 最简单的 Notification、Application Context 应用于 Notification
android·java·开发语言·junit·android studio·android jetpack·android-studio
android_cai_niao9 天前
JUnit 4.x最新版本
junit·junit5·junit4
快乐肚皮10 天前
OpenResty:Nginx的进化之路
nginx·junit·openresty
别会,会就是不问10 天前
Junit4下Mockito包的使用
java·junit·单元测试
我命由我1234511 天前
JUnit - 自定义 Rule
android·java·开发语言·数据库·junit·java-ee·android-studio
剑之所向12 天前
嵌入式之lua脚本
开发语言·junit·lua
weixin_4624462318 天前
在宝塔 Nginx 上安装与配置 lua-cjson 教程
nginx·junit·lua
移幻漂流21 天前
Lua的现状与机遇:技术生态全景及高潜力领域分析
junit·单元测试·lua