日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux 安装 luarocks(lua的模块管理工具)

發布時間:2024/9/20 linux 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux 安装 luarocks(lua的模块管理工具) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、簡介

該軟件包可以安裝和更新lua的第三方模塊。

?

2、下載地址

請在 http://luarocks.org/releases/ 頁面選擇需要的軟件包。

wget http://luarocks.org/releases/luarocks-2.1.0.tar.gz

?

3、安裝

tar -zxvf luarocks-2.1.0.tar.gz

cd luarocks-2.1.0

./configure --prefix=/usr/local/luarocks

make build

make install

OK了,luarock的可執行文件被安裝到了 /usr/local/luarocks/bin/luarocks.

?

4、使用(暫時把英文直接copy過來,有時間再翻譯)

使用luarocks安裝lua模塊的示例:

?

luarocks install luasocket

luarocks install luasql-sqlite3

luarocks install lpeg

luarocks install lzlib

luarocks install luafilesystem

luarocks install luasec

luarocks install md5

luarocks install luacurl

luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql MYSQL_LIBDIR=/usr/lib64/mysql/ (mysql的各種路徑自己locate去找吧 = = !)

luarocks install lua-cjson

?

1.模塊安裝后如果在程序require的時候提示找不到相應模塊則可以在luarocks和lua之間做一個軟鏈接:

例如安裝完luasql-mysql之后可能在程序中require的時候會提示找不到模塊,這時候我們可以:

cd /usr/local/lib/lua/5.1/

mkdir luasql

ln -s /usr/local/luarocks/lib/lua/5.1/luasql/mysql.so /usr/local/lib/lua/5.1/luasql/mysql.so

?

2.運行時提示attempt to index global 'luasql' (a nil value) 代碼里面require "luasql.mysql"需要這樣寫

luasql = require "luasql.mysql"


?

Usage

luarocks [--server=server | --only-server=server] [--tree=tree] [--only-sources=url] [--deps-mode=mode] [VAR=VALUE]...command [argument]

?

Variables from the "variables" table of the configuration file can be overriden with VAR=VALUE assignments.

--server=serverFetch rocks/rockspecs from this server (takes priority over config file)
--only-server=serverFetch rocks/rockspecs from this server only (overrides any entries in the config file)
--only-sources=urlRestrict downloads of sources to URLs starting with the given URL. For example, --only-sources=http://luarocks.org will allow LuaRocks to download sources only if the URL given in the rockspec starts with http://luarocks.org .
--tree=treeWhich tree to operate on.
--deps-mode=modeSelect dependencies mode:

How to handle the list of rocks servers given in the rocks_servers array in theconfig file.

  • one - Consider only the tree at the top of the list (possibly, the one given by the --tree flag, overriding all entries from rocks_trees), ignore all others
  • all - Consider all trees: if a dependency is installed in any tree of the rocks_trees list, we have a positive match.
  • order - Consider only trees starting from the "current" one in the order, where the "current" is either:
    • the one at the bottom of the rocks_trees list,
    • or one explicitly given with --tree
    • or the "home" tree if --local was given or local_by_default=true is configured (usually at the top of the list)

?

Supported commands

?

?

buildBuild/compile and install a rock.
downloadDownload a specific rock or rockspec file from a rocks server.
helpHelp on commands.
installInstall a rock.
listLists currently installed rocks.
makeCompile package in current directory using a rockspec and install it.
packCreate a rock, packing sources or binaries.
pathReturn the currently configured package path.
removeUninstall a rock.
searchQuery the LuaRocks repositories.
showShows information about an installed rock.
unpackUnpack the contents of a rock.

?

Overview of the difference between "make", "build", "install" and "pack"

?

?

luarocks install modulenamedownloads a binary .rock file and installs it to the local tree (falls back to "luarocks build modulename" behavior if a binary rock is not found)
luarocks build modulenamedownloads a .src.rock or a rockspec and builds+installs it to the local tree.
luarocks build modulename-1.0-1.linux-x86.rockextracts the rockspec from the rock and builds it as if the rockspec was passed in the command-line (i.e., redownloading sources and recompiling C modules if any).
luarocks build modulename-1.0-1.rockspecbuilds+installs the rock using the given rockspec downloading the sources
luarocks make modulename-1.0-1.rockspecbuilds+installs the rock using the rockspec using the contents of your current directory (kind of like the way make uses a Makefile) instead of downloading sources
luarocks pack modulenamegrabs the rock from your local tree and packs it into a binary .rock file
luarocks pack modulename-1.0-1.rockspecdownloads the sources from the url and packs it into a .src.rock file

來源:http://www.linuxidc.com/Linux/2014-01/95501.htm

總結

以上是生活随笔為你收集整理的Linux 安装 luarocks(lua的模块管理工具)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。