Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在openresty docker映像中安装LuaRESTY字符串?_Lua_Openresty - Fatal编程技术网

如何在openresty docker映像中安装LuaRESTY字符串?

如何在openresty docker映像中安装LuaRESTY字符串?,lua,openresty,Lua,Openresty,我想在openresty代码中使用sha256,因此尝试安装lua resty string 很明显,我遗漏了一些其他包,但不知道是哪些包。这张照片没有我能看到的线索 $ docker run --rm -it openresty/openresty bash # apt-get update && apt-get install luarocks # luarocks install lua-resty-string Installing https://luarocks.or

我想在openresty代码中使用sha256,因此尝试安装
lua resty string

很明显,我遗漏了一些其他包,但不知道是哪些包。这张照片没有我能看到的线索

$ docker run --rm -it openresty/openresty bash
# apt-get update && apt-get install luarocks
# luarocks install lua-resty-string
Installing https://luarocks.org/lua-resty-string-0.09-0.rockspec
lua-resty-string 0.09-0 is now installed in /usr/local (license: )
root@28fe64c51c5a:/# luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
> resty_sha256 = require "resty.sha256"
> sha256 = resty_sha256:new()
/usr/local/share/lua/5.1/resty/sha256.lua:41: luajit: undefined symbol: SHA256_Init
stack traceback:
    [C]: in function '__index'
    /usr/local/share/lua/5.1/resty/sha256.lua:41: in function 'new'
    stdin:1: in main chunk
    [C]: at 0x55cd1fdaf250
如果Luarock能够正确地构建或安装软件,我会更加相信它


(这次)我遗漏了什么?

似乎
lua resty string
包只有在
nginx
服务器执行代码时才起作用

root@62817b2fe1b2:/# ldd `which nginx`
    linux-vdso.so.1 (0x00007ffe3b1db000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa367a81000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa367a60000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fa367a26000)
    libluajit-5.1.so.2 => /usr/local/openresty/luajit/lib/libluajit-5.1.so.2 (0x00007fa3679a3000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa367820000)
    libpcre.so.1 => /usr/local/openresty/pcre/lib/libpcre.so.1 (0x00007fa3677ad000)
    libssl.so.1.1 => /usr/local/openresty/openssl/lib/libssl.so.1.1 (0x00007fa367739000)
    libcrypto.so.1.1 => /usr/local/openresty/openssl/lib/libcrypto.so.1.1 (0x00007fa3674ad000)
    libz.so.1 => /usr/local/openresty/zlib/lib/libz.so.1 (0x00007fa367490000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa3672cf000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa367c97000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa3672b5000)
root@62817b2fe1b2:/# nm -D /usr/local/openresty/openssl/lib/libcrypto.so.1.1 | grep SHA256_Init
00000000001b12a0 T SHA256_Init
该库附带了openresty:

root@62817b2fe1b2:/# dpkg -S /usr/local/openresty/openssl/lib/libcrypto.so.1.1
openresty-openssl: /usr/local/openresty/openssl/lib/libcrypto.so.1.1
因此,我想真正的问题是,如何告诉luajit加载该库,以便在导入
resty.SHA256
时它可以解析
SHA256_Init

而且似乎可以通过
ffi

local ffi = require("ffi")
local crypto = ffi.load("/usr/local/openresty/openssl/lib/libcrypto.so.1.1", true)