How to configure an elegant set of LUA development environments

Source: Internet
Author: User
Tags lua

Discussion of how an elegant development environment is deployed (this article discusses the same for other platforms in the MACOSX platform) elegant LUA development environment

The elegant LUA development environment includes at least the following: Install the latest stable version of Lua suitable for your needs, install the appropriate LUA Package Manager (recommended for Luarocks, install in another article) source installation (Reasonable organization installation directory, setting environment variables makes the LUA environment easier to use and easy to manage) Version Selection

First of all, we should pay attention to the current popular LUA version (5.1x,5.2x,5.3x), how to choose my opinion is based on their own needs, choose the latest stable version of their own.

My environment is used for Web application development based on Openresty (Openresty is a derived version of Nginx with its Http_lua module), and the execution of LUA code in Openresty is resolved and accelerated by Luajit, and Luajit based on Lua5.1x's ABI development, Openresty officially pointed out that using Luajit to run LUA code is the best solution, so there is no doubt lua5.1x is the most suitable for me, the latest stable version of Lua5.1.5. Installation Deployment

Compared to brew, Apt-get, Yum and other installation methods, I would recommend the use of the source code installation, so as to help us to the whole environment details have more understanding and grasp, reasonable organization installation directory, combined with environment variable settings, easy to use and management.

Download and unzip the LUA source code:

wget http://www.lua.org/ftp/lua-5.1.5.tar.gz
tar zxvf lua-5.1.5.tar.gz
CD lua-5.1.5

Open makefile, you can see the following information:

plat= None                 #安装平台, default platform is none
install_top=/usr/local     #安装跟目录, default is/usr/local

# convenience platforms Targets.    #源码所支持的平台
plats= AIX ANSI BSD FreeBSD generic Linux macosx MinGW POSIX solaris

Change Install_top to your established installation directory and save

install_top=/usr/local/lua-5.1.5

Continue with the following steps to install:

Make MacOSX         #编译平台设置为macosx, and the other platforms will replace MACOSX directly, such as the Do Linux make
macosx install  #安装平台设置为macosx

After successful installation, the following:

~/desktop/ll/usr/local/lua-5.1.5 Total
0
drwxr-xr-x  4 root  wheel   136B 18:48 bin
Drwxr-xr-x  7 root  wheel   238B 18:48 include
drwxr-xr-x  4 root  wheel   136B 10 19 18:48 Lib
drwxr-xr-x  3 root  wheel   102B 18:48 man
drwxr-xr-x  3 root  wheel   102B 18:48 Share

Run Lua-v to see which version of Lua is installed

~/desktop/lua-v
Zsh:command not Found:lua
~/desktop/ln-sf/usr/local/lua-5.1.5/bin/lua/usr/local/bin/lu A
~/desktop/lua-v
lua 5.1.5  Copyright (C) 1994-2012 lua.org, Puc-rio

The above installation is to get a LUA executable, the elegance of the use of source installation, the organization of the installation directory makes it easier for us to manage the LUA environment, the future Lua5.1.5 version of the relevant ABI, LUA package will be installed in the installation directory under the Lib,share path, We can even define lua_path=/usr/local/lua-5.1.5 to be more convenient to reference lua.h and so on to do related module development.

Because the specified installation directory/usr/local/lua-5.1.5 is not under the PATH environment variable, direct execution of LUA will report command not Found:lua, Here we use the method of adding a soft connection to link the executable file to a path path with the same effect, or you can add/usr/local/lua-5.1.5/bin directly to the environment variable path. Multi-version coexistence

Multi-version coexistence can be achieved naturally with source installation

~/desktop/luarocks-2.2.2/ll/usr/local/lua*
/usr/local/lua:
/usr/local/lua-5.1.5:
/usr/local/ lua-5.2.3:
/usr/local/lua-5.3.1:

//ll/usr/local/bin/lua*
lrwxr-xr-x  1 root  admin    28B 10 23:16/usr/local/bin/lua-/usr/local/lua-5.1.5/bin/lua
lrwxr-xr-x  1 root  admin    28B 10 20 10:08/usr/local/bin/lua52-/usr/local/lua-5.2.3/bin/lua
lrwxr-xr-x  1 root  admin    28B 10 20 10:12/usr/local/bin/lua53-/usr/local/lua-5.3.1/bin/lua
lrwxr-xr-x  1 root  admin    29B 10 20 10:12/usr/local/bin/luac-/usr/local/lua-5.1.5/bin/luac
lrwxr-xr-x  1 root  admin    29B 10 20 10:08/USR/LOCAL/BIN/LUAC52-/usr/local/lua-5.2.3/bin/luac
lrwxr-xr-x  1 root  admin    29B 10 10:11/usr/local/bin/luac53-/usr/local/lua-5.3.1/bin/luac

Lua language 15-minute QuickStart http://www.linuxidc.com/Linux/2013-06/86582.htm

Lua Programming (2nd edition) Chinese PDF http://www.linuxidc.com/Linux/2013-03/81833.htm

Lua Programming (second Edition) Read note http://www.linuxidc.com/Linux/2013-03/81834.htm

NetBSD will support the development of kernel components with Lua scripts http://www.linuxidc.com/Linux/2013-02/79527.htm

CentOS compiler installs Lua Luasocket http://www.linuxidc.com/Linux/2011-08/41105.htm

Programming in Lua HD PDF Chinese http://www.linuxidc.com/Linux/2015-05/117362.htm

a detailed description of Lua : please click here
download address for Lua : please click here

This article permanently updates the link address : http://www.linuxidc.com/Linux/2015-10/124397.htm

Source: http://www.linuxidc.com/Linux/2015-10/124397.htm

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.