openresty利用lua_package_path來引入moudule模塊

1.自定義模塊nginx

local my_module={}


function my_module.find_number(a,b)
   return a+b
end

return my_module

2。nginx.conf文件配置(放於http裏面的配置)app

lua_package_path "/Users/guanguan/workspace/knifer/?.lua;;";


    server {
        listen       8000;
        server_name  localhost;


        set $path /Users/guanguan/workspace/knifer/app;

 
        location / {
            lua_check_client_abort on;
            access_by_lua_file  $path/main.lua;
        }

    access_log   /usr/local/openresty/nginx/logs/knifer_access.log  main;
    error_log    /usr/local/openresty/nginx/logs/knifer_error.log  debug;
    }

3.引入自定義模塊ui

local common = require "lib.utils.common"
相關文章
相關標籤/搜索