有勇气的牛排博客

lua扩展库luarocks安装

有勇气的牛排 1333 lua 2024-09-07 15:15:33

前言

LuaRocks 是一个用于管理和分发 Lua 模块的包管理器。它让 Lua 开发者可以轻松安装、更新、管理和发布 Lua 库和模块。通过 LuaRocks,开发者可以访问和分享成千上万的 Lua 模块,并自动处理依赖关系和版本控制问题。

下載安裝

CentOS

https://luarocks.org/

https://luarocks.github.io/luarocks/releases/

cd /usr/local/openresty
tar zxpf luarocks-3.11.1.tar.gz cd luarocks-3.11.1
./configure --with-lua=/usr/local/openresty/openresty_install/luajit --with-lua-include=/usr/local/openresty/openresty_install/luajit/include
make && make install

配置

# 案例 luarocks config variables.LUA_INCDIR /usr/local/lua/include luarocks config variables.LUA_LIBDIR /usr/local/lua/lib # 配置 luarocks config variables.LUA_LIBDIR /usr/local/openresty/openresty_install/luajit/lib

Windows

https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Windows

下载

https://luarocks.github.io/luarocks/releases/

打开命令提示符,导航到 LuaRocks 的解压目录:

cd E:\soft\lua\luarocks-3.11.1-windows-64

添加path

E:\soft\lua\luarocks-3.11.1-windows-64 C:\Program Files (x86)\Lua\5.1

使用以下命令将 Lua 的路径与 LuaRocks 绑定:

luarocks config --local variables.LUA_DIR "C:\Program Files (x86)\Lua\5.1"

luarocks --lua-dir="C:\Program Files (x86)\Lua\5.1" install penlight

常用命令

作者:有勇气的牛排
https://www.couragesteak.com/article/473

查看安裝

luarocks list

安裝

luarocks install lua-resty-http 0.14

卸載

luarocks remove lua-resty-http

搜索

luarocks search <query>
luarocks search http

显示模块信息

luarocks info <module_name> [version]

显示指定模块的信息,包括描述、版本等。例如:

luarocks info lua-resty-http

清理未使用模塊

luarocks purge

更新模塊

luarocks update lua-resty-http

检查 LuaRocks 的配置

luarocks config

常用包安裝

luarocks install lua-resty-http luarocks install lua-cjson luarocks install lua-resty-mysql luarocks install lua-resty-redis

mysql

luarocks install luasql-mysql luarocks install luasql-mysql MYSQL_DIR=/var/lib/mysql MYSQL_INCDIR=/usr/include/mysql

redis

luarocks install redis-lua # lua-resty-redis-util https://github.com/anjia0532/lua-resty-redis-util

留言

专栏
文章
加入群聊