国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

nginx - openresty無法使用require

瀏覽:190日期:2024-06-26 11:21:03

問題描述

不使·access_check.lua的時候,程序運行正常,使用就會出現(xiàn)錯誤。環(huán)境使用了docker的openresty/openresty官方鏡像。

nginx.conf配置如下:

worker_processes 1;error_log logs/error.log;events { worker_connections 1024;}http { lua_package_path 'lua/?.lua;app/?.lua'; lua_code_cache off; server {listen 6699;charset utf-8;#lua_need_request_body on;location / { default_type text/html; content_by_lua_block {ngx.say('hello fatrbaby') }}location ~ ^/api/([-_a-zA-Z0-9/]+) { access_by_lua_file lua/access_check.lua; content_by_lua_file lua/$1.lua;} }}

access_check.lua代碼如下:

local validator = require('lib.validator')local args = ngx.req.get_uri_args()if not validator.is_number(args.a, args.b) then ngx.exit(ngx.HTTP_BAD_REQUEST) returnendngx.print(package.path)

錯誤日志如下:

2017/04/26 09:11:34 [error] 216#216: *1 lua entry thread aborted: runtime error: /usr/local/var/learn/lua/access_check.lua:1: module ’lib.validator’ not found: no field package.preload[’lib.validator’] no file ’lua/lib/validator.lua’ no file ’app/lib/validator.lua’ no file ’/usr/local/openresty/site/lualib/lib/validator.so’ no file ’/usr/local/openresty/lualib/lib/validator.so’ no file ’./lib/validator.so’ no file ’/usr/local/lib/lua/5.1/lib/validator.so’ no file ’/usr/local/openresty/luajit/lib/lua/5.1/lib/validator.so’ no file ’/usr/local/lib/lua/5.1/loadall.so’ no file ’/usr/local/openresty/site/lualib/lib.so’ no file ’/usr/local/openresty/lualib/lib.so’ no file ’./lib.so’ no file ’/usr/local/lib/lua/5.1/lib.so’ no file ’/usr/local/openresty/luajit/lib/lua/5.1/lib.so’ no file ’/usr/local/lib/lua/5.1/loadall.so’stack traceback:coroutine 0: [C]: in function ’require’ /usr/local/var/learn/lua/access_check.lua:1: in function </usr/local/var/learn/lua/access_check.lua:1>, client: 172.17.0.1, server: , request: 'GET /api/add?a=1&b=6 HTTP/1.1', host: 'localhost:6699'

項目目錄結(jié)構(gòu)如下:

nginx - openresty無法使用require

問題解答

回答1:

已經(jīng)解決了這個問題

相關(guān)文章:
主站蜘蛛池模板: 普定县| 融水| 大关县| 探索| 疏勒县| 宁城县| 永吉县| 万宁市| 岳阳县| 鹤壁市| 蒙山县| 松潘县| 鲁甸县| 福海县| 咸阳市| 陵川县| 乌兰察布市| 长寿区| 丰县| 乐至县| 丹寨县| 湖口县| 萨嘎县| 濮阳县| 大田县| 静乐县| 富民县| 商水县| 滦平县| 兴海县| 永新县| 天水市| 奉化市| 奉节县| 罗田县| 建平县| 桐庐县| 大宁县| 孝昌县| 兴城市| 颍上县|