|
Topic of discussion
What is an elegant development environment
How to deploy (This article discusses MacOSX platform, other platforms are also applicable)
Elegant Lua development environment
Elegant Lua development environment includes at least the following:
Installation suited to the needs of the latest stable version Lua
Lua install the appropriate package manager (recommended Luarocks, install see another article)
Source Installation (rational organizational installation directory, set the environment variable to make Lua environment easier to use and easy to manage)
Version Selection
First, we pay attention to a variety of popular Lua current version (5.1x, 5.2x, 5.3x), my point is how to choose according to their needs, choose the latest stable version.
I used to do environmental Openresty (Openresty Nginx is a combination of a module Http_lua its derivative version) of the Web-based application development, execution Openresty in Lua parsing code through LuaJit and acceleration, while LuaJit based ABI Lua5.1x of development, Openresty official made clear that the use of LuaJit run Lua code is the optimal solution, so no doubt Lua5.1x is best for me, the latest stable version of Lua5.1.5.
Installation Deployment
Compared to brew, apt-get, yum, etc. installation, I recommend using the source installation, so help us to have more understanding and grasp of the details of the environment, rational organization installation directory, combined to set environment variables, and easy to use 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 the Makefile, you can see the following information:
PLAT = none # installation platform, the default platform is none
INSTALL_TOP = / usr / local # with the installation directory, defaults to / usr / local
# Convenience platforms targets. # Source supported platforms
PLATS = aix ansi bsd freebsd generic linux macosx mingw posix solaris
Save the INSTALL_TOP modify your installation directory after a given
INSTALL_TOP = /usr/local/lua-5.1.5
Continue the installation as follows:
make macosx # compiler platform set macosx, other platforms can be replaced directly macosx, such as make linux
make macosx install # install platform set macosx
After a successful installation as follows:
~ / Desktop / ll /usr/local/lua-5.1.5
total 0
drwxr-xr-x 4 root wheel 136B 10 19 18:48 bin
drwxr-xr-x 7 root wheel 238B 10 19 18:48 include
drwxr-xr-x 4 root wheel 136B 10 19 18:48 lib
drwxr-xr-x 3 root wheel 102B 10 19 18:48 man
drwxr-xr-x 3 root wheel 102B 10 19 18:48 share
Run lua -v Lua Version View installed
~ / Desktop / lua -v
zsh: command not found: lua
~ / Desktop / ln -sf /usr/local/lua-5.1.5/bin/lua / usr / local / bin / lua
~ / Desktop / lua -v
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
Installation project was supported by more than a Lua executable file, elegant place in that source installation, the installation directory to make our organization more easily manage Lua environment, future versions Lua5.1.5 related ABI, Lua and other packages will be installed to the installation directory the lib, under the share path, we can even define LUA_PATH = / usr / local / lua-5.1.5 to be more convenient and so do the related references lua.h module development.
Because the installation directory you specify /usr/local/lua-5.1.5 not in the PATH environment variable, it will be reported directly to the Executive lua command not found: lua, here we use the Add soft connection will link the executable file path to PATH By reaching the same effect can also be directly /usr/local/lua-5.1.5/bin added to your PATH environment variable.
The coexistence of multiple versions
Use natural source installation can implement multiple versions coexist
~ / 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 19 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 20 10:11 / usr / local / bin / luac53 -> /usr/local/lua-5.3.1/bin/luac |
|
|
|