1、OpenResty1.15.8.2版本已经包含并默认安装了opm。所以你不需要自己安装opm,我们只需要做一个软连接就可以了。
2、进入openresty的bin目录下,可以看到opm
cd /usr/local/openresty/bin
[root@ZYL /]# cd /usr/local/openresty/bin/
[root@ZYL bin]# ls
md2pod.pl nginx-xml2pod openresty opm resty restydoc restydoc-index
[root@ZYL bin]#
3、给opm做个软连接
ln -s pwd
/opm /usr/local/bin/opm
非root用户需在软连接前加上sudo: sudo ln -s pwd
/opm /usr/local/bin/opm
[root@ZYL bin]# ln -s `pwd`/opm /usr/local/bin/opm
(如果软连接不成功,需要安装安装了perl-Digest-MD5后,问题即可解决。yum -y install perl-Digest-MD5)
查看是否连接成功:
opm --help
[root@ZYL bin]# opm --help
opm [options] command package...
Options:
-h
--help Print this help.
--install-dir=PATH Install into the specified PATH directory instead of the system-wide
OpenResty installation tree containing this tool.
--cwd Install into the current working directory under ./resty_modules/
instead of the system-wide OpenResty installation tree containing
this tool.
Commands:
build Build from the current working directory a package tarball ready
for uploading to the server.
clean ARGUMENT... Do clean-up work. Currently the valid argument is "dist", which
cleans up the temporary files and directories created by the "build"
command.
info PACKAGE... Output the detailed information (or meta data) about the specified
packages. Short package names like "lua-resty-lock" are acceptable.
get PACKAGE... Fetch and install the specified packages. Fully qualified package
显示如上,那么恭喜你连接成功了。
4、opm的使用
搜索指定软件包名称
opm search session
[root@ZYL bin]# opm search session
bungle/lua-resty-session Session Library for OpenResty - Flexible and Secure
搜索具有多个模式“lru”和“cache”的软件包名称和摘要。
opm search lru cache
[root@ZYL bin]# opm search lru cache
openresty/lua-resty-lrucache Lua-land LRU Cache based on LuaJIT FFI
附:
#show usage.
opm --help
#search package names and abstracts with the user pattern “lock”.
opm search lock
#search package names and abstracts with multiple patterns “lru” and “cache”.
opm search lru cache
#install a package named lua-resty-foo under the name of some_author
opm get some_author/lua-resty-foo
#get a list of lua-resty-foo packages under all authors.
opm get lua-resty-foo
#show the details of the installed package specified by name.
opm info lua-resty-foo
#show all the installed packages.
opm list
#upgrade package lua-resty-foo to the latest version.
opm upgrade lua-resty-foo
#update all the installed packages to their latest version.
opm update
#uninstall the newly installed package
opm remove lua-resty-foo