Openresty 学习笔记(一)opm 工具的使用
1、自1.11.2.2开始,OpenResty版本已经包含并默认安装opm。所以通常你不需要自己安装opm。
2、我们在这里只需要做一个软连接就可以了
cd /usr/local/openresty/bin
sudo ln -s `pwd`/opm /usr/local/bin/opm
3、搜索指定软件包名称
www@TinywanAliYun:~$ opm search session
bungle/lua-resty-session Session Library for OpenResty - Flexible and Secure
4、搜索具有多个模式“lru”和“cache”的软件包名称和摘要。
www@TinywanAliYun:~$ opm search lru cache
openresty/lua-resty-lrucache Lua-land LRU Cache based on LuaJIT FFI
5、在一些作者的名字下安装名为lua-resty-logger-socket的软件包
www@TinywanAliYun:~$ opm get p0pr0ck5/lua-resty-logger-socket* Fetching p0pr0ck5/lua-resty-logger-socket
Downloading https://opm.openresty.org/api/pkg/tarball/p0pr0ck5/lua-resty-logger-socket-0.03.opm.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7423 100 7423 0 0 23691 0 --:--:-- --:--:-- --:--:-- 23715
Package p0pr0ck5/lua-resty-logger-socket 0.03 installed successfully under /usr/local/openresty/site/ .
结果在 /usr/local/openresty/lualib/resty 目录下没有这个文件下载下来
结果该文件默认下载到以下目录了
1 | /usr/local/openresty/site/lualib/resty |
编写代码测试
1 2 | local uuid = require 'resty.jit-uuid' ngx.say(uuid()) |
问题来了,项目中直接应用,报错,提示找不到该文件
1 2 3 4 5 6 7 8 9 10 | [C]: in function 'require' in function /status " [error] 7626 #7626: init_worker_by_lua error: init_worker_by_lua:2: module 'resty.jit-uuid' not found: no field package.preload[ 'resty.jit-uuid' ] no file '/usr/local/openresty/lualib/resty/jit-uuid.lua' no file '/usr/local/openresty/nginx/conf/waf/resty/jit-uuid.lua' no file '/usr/local/openresty/lualib/resty/jit-uuid.so' no file '/opt/verynginx/verynginx/lua_script/resty/jit-uuid.so' no file '/usr/local/openresty/site/lualib/resty/jit-uuid.so' no file '/usr/local/openresty/lualib/resty/jit-uuid.so' |
如果复制到该目录下,则是可以正常访问的
1 | /usr/local/openresty/lualib/resty |
要想安装到以上目录
则在下载的时候指定安装目录就可以了
1 | opm -- install - dir = /usr/local/openresty get thibaultcha /lua-resty-jit-uuid |
通过上面这种安装方式,直接在项目中就可以使用
参考
标签:
Openresty
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构