Linux installation Luarocks (LUA's module management tool)

Source: Internet
Author: User
Tags lua unpack

1. Introduction

The package can install and update LUA's third-party modules.

2.

Please select the desired package on the http://luarocks.org/releases/page.

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

3. Installation

TAR-ZXVF luarocks-2.1.0.tar.gz

CD luarocks-2.1.0

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

Make Build

Make install

OK, Luarock's executable is installed to/usr/local/luarocks/bin/luarocks.

4, use (temporarily copy the English directly, there is time to translate)

example of installing a LUA module using luarocks:

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's various paths locate go find it yourself. = =! )

Luarocks Install Lua-cjson

1. After the module is installed, if you are prompted to find the appropriate module when the program require, you can make a soft link between luarocks and Lua:

For example, after the installation of Luasql-mysql may be in the program when the require will be prompted to find the module, this time we can:

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. Runtime prompt attempt to index global ' luasql ' (a nil value) code inside require "Luasql.mysql" need to write like this

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 is overriden with var=value assignments.

--server=Server Fetch Rocks/rockspecs from the This server (takes-priority-over config file)
--only-server=Server Fetch Rocks/rockspecs from this server only (overrides any entries in the config file)
--only-sources=URL Restrict downloads of sources to URLs starting with the given URL. For example,--only-sources=http://luarocks.org would allow luarocks to download sources only if the URL given in the rocks PEC starts with http://luarocks.org.
--tree=Tree Which tree to operate on.
--deps-mode=Mode Select 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  -Con Sider all Trees:if a dependency are installed in any tree of the rocks_trees list and we have a positive match.
  • Order  -Consider only trees starting from the ' current ' one in the order, where the ' C Urrent "is either:
    • the one at the bottom of the Rocks_trees list,
    • or one explicitly giv En with--tree
    • or the ' home ' tree if--local was given or local_by_default=true are configured (usually at The top of the list)

Supported commands

Build Build/compile and install a rock.
Download Download a specific rock or rockspec file from a rocks server.
Help Help on Commands.
Install Install a rock.
List Lists currently installed rocks.
Make Compile package in the current directory using a rockspec and install it.
Pack Create a rock, packing sources or binaries.
Path Return the currently configured package path.
Remove Uninstall a rock.
Search Query the Luarocks repositories.
Show Shows information about an installed rock.
Unpack Unpack the contents of a rock.

Overview of the difference between "make", "Build", "Install" and "pack"

Luarocks Install ModuleName Downloads a binary. Rock file and installs it to the local tree (falls back to "luarocks build modulename" behavior if a B Inary Rock is not found)
Luarocks Build ModuleName Downloads A. Src.rock or a rockspec and builds+installs it to the local tree.
Luarocks Build Modulename-1.0-1.linux-x86.rock Extracts the Rockspec from the rock and builds it as if the Rockspec is passed in the command-line (i.e., redownloading s Ources and recompiling C modules if any).
Luarocks Build Modulename-1.0-1.rockspec Builds+installs The rock using the given rockspec downloading the sources
Luarocks make Modulename-1.0-1.rockspec Builds+installs The rock using the Rockspec using the contents of the Your current directory (kind of the-the-the-the-make uses a Makefile) instead of downloading sources
Luarocks Pack ModuleName Grabs the rock from your local tree and packs it into a binary. Rock file
Luarocks Pack Modulename-1.0-1.rockspec Downloads the sources from the URL and packs it into a. src.rock file

Linux installation Luarocks (LUA's module management tool)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.