博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx lua 01
阅读量:4622 次
发布时间:2019-06-09

本文共 1179 字,大约阅读时间需要 3 分钟。

  1. content_by_lua     location /lua {      content_by_lua '        ngx.say("hello content_by_lua");      ';    }      2. content_by_lua_file        location /lua {            content_by_lua_file lua/test.lua ;        }        #这个文件必须是nginx的--prefix目录下才行。         ├── client_body_temp [error opening dir]        ├── fastcgi_temp [error opening dir]        ├── html        │   ├── 50x.html        │   └── index.html        ├── lua        │   └── test.lua        ├── proxy_temp [error opening dir]        ├── sbin        │   └── nginx        ├── scgi_temp [error opening dir]        └── uwsgi_temp [error opening dir]

 

 

2. lua_package_path

1. 指定位置    lua_package_path "/usr/local/etc/openresty/lua/?.lua;;";    2. location配置    location / {        content_by_lua_file lua/test.lua;    }    3. cat /usr/local/etc/openresty/lua/test.lua        local _M = {}        function _M:new()        -- 不能有local,不然外面找不到这个方法        ngx.say("this is t")        end        return _M        4.  cat test.lua              local t = require "test";              t:new();              ngx.say("lua hello");       # lua_package_path 就是为了require用的。

 

 

 

转载于:https://www.cnblogs.com/nika86/p/10984329.html

你可能感兴趣的文章
【入门】求1!+2!+...+N!
查看>>
day-19 多种优化模型下的简单神经网络tensorflow示例
查看>>
索引的重要性
查看>>
Spring源码情操陶冶-AOP之Advice通知类解析与使用
查看>>
Gym 101081K Pope's work dp
查看>>
大文件跨服务器传送
查看>>
乱七八糟集合
查看>>
【Java SE】斐波那契数列
查看>>
六、变量\字符编码
查看>>
VSCode快捷键
查看>>
学习进度_第九周
查看>>
SessionHelper
查看>>
python 自己写个树形展示
查看>>
.Net 发邮件
查看>>
结对编程项目作业1
查看>>
JavaScript Map数据结构
查看>>
jsp防盗链代码
查看>>
asp.NET配置
查看>>
Js apply方法详解
查看>>
2013 Multi-University Training Contest 4 Who's Aunt Zhang
查看>>