Openresty 学习笔记(一)opm 工具的使用
生活随笔
收集整理的這篇文章主要介紹了
Openresty 学习笔记(一)opm 工具的使用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、自1.11.2.2開(kāi)始,OpenResty版本已經(jīng)包含并默認(rèn)安裝opm。所以通常你不需要自己安裝opm。
2、我們?cè)谶@里只需要做一個(gè)軟連接就可以了
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、搜索具有多個(gè)模式“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/ .
結(jié)果在 /usr/local/openresty/lualib/resty 目錄下沒(méi)有這個(gè)文件下載下來(lái)
結(jié)果該文件默認(rèn)下載到以下目錄了
/usr/local/openresty/site/lualib/resty
編寫代碼測(cè)試
local uuid = require 'resty.jit-uuid' ngx.say(uuid())
問(wèn)題來(lái)了,項(xiàng)目中直接應(yīng)用,報(bào)錯(cuò),提示找不到該文件
[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'
如果復(fù)制到該目錄下,則是可以正常訪問(wèn)的
/usr/local/openresty/lualib/resty
要想安裝到以上目錄
則在下載的時(shí)候指定安裝目錄就可以了
opm --install-dir=/usr/local/openresty get thibaultcha/lua-resty-jit-uuid
通過(guò)上面這種安裝方式,直接在項(xiàng)目中就可以使用
參考
1、OpenResty 大躍進(jìn)! opm 包管理嘗鮮
總結(jié)
以上是生活随笔為你收集整理的Openresty 学习笔记(一)opm 工具的使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何找到一个前端事件对应的事件处理函数
- 下一篇: SAP UI5框架渲染的顺序