我已经安装了luasocket
Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require("socket.http")
table: 0x9b2d80
>
debian:/usr/local/share/lua/5.3/socket# ll
total 56
-rw-r--r-- 1 root root 10640 Dec 22 17:47 ftp.lua
-rw-r--r-- 1 root root 3698 Dec 22 17:47 headers.lua
-rw-r--r-- 1 root root 13216 Dec 22 17:47 http.lua
-rw-r--r-- 1 root root 8074 Dec 22 17:47 smtp.lua
-rw-r--r-- 1 root root 3766 Dec 22 17:47 tp.lua
-rw-r--r-- 1 root root 11105 Dec 22 17:47 url.lua
在Haproxy Lua代码中:
local http = require("socket.http")
当我请求网络时,
runtime error: /etc/haproxy/waf/lib.lua:7: module 'socket.http' not found:#012#011no field package.preload['socket.http']#012#011no file '/usr/local/share/lua/5.3/socket/http.lua'#012#011no file '/usr/local/share/lua/5.3/socket/http/init.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http/init.lua'#012#011no file '/usr/share/lua/5.3/socket/http.lua'#012#011no file '/usr/share/lua/5.3/socket/http/init.lua'#012#011no file './socket/http.lua'#012#011no file './socket/http/init.lua'#012#011no file '/etc/haproxy/waf/socket/http.lua'#012#011no file '/etc/haproxy/waf/socket/http.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http.so'#012#011no file '/usr/lib/x86_64-linux-gnu/lua/5.3/socket/http.so'#012#011no file '/usr/lib/lua/5.3/socket/http.so'#012#011no file '/usr/local/lib/lua/5.3/loadall.so'#012#011no file './socket/http.so'#012#011no file '/usr/local/lib/lua/5.3/socket.so'#012#011no file '/usr/lib/x86_64-linux-gnu/lua/5.3/socket.so'#012#011no file '/usr/lib/lua/5.3/socket.so'#012#011no file '/usr/lo
谁可以帮助我。 THX
答案 0 :(得分:0)
您的计算机找不到所需的文件。
https://www.lua.org/pil/8.1.html
要确定其路径,首先需要检查全局变量 LUA_PATH。如果LUA_PATH的值是一个字符串,那么该字符串就是 路径。否则,需要检查环境变量LUA_PATH。 最后,如果两个检查都失败,则需要使用固定路径(通常 "?;?。lua",虽然在编译Lua时很容易改变它。)
LUA_PATH的内容将被复制到package.path中。因此,要么将该模块的位置添加到运行Lua的系统变量中,要么将其添加到package.path befor require。