Build Environment on Windows
Since version 1.9.3.2, OpenResty has officially released and maintained the Windows version, which directly contains the latest compiled version of LuaJIT. Because of the relatively good binary compatibility of the Windows operating system itself, users only need to download and decompress two steps.
Open http://openresty.org and select the Download connection on the left. Then we can download the latest version of OpenResty (for example, the latest version of the author’s book: ngx_openresty-1.9.7.1-win32.zip). After the local download is successful, perform decompression and you can see the directory structure shown in the following figure:
Double-click on LuJIT.exe in the figure to enter command line mode, where we can directly complete simple Lua syntax interaction.
Build Environment on Linux, Mac OS X
Go to LuaJIT’s official website http://luajit.org/download.html to see the latest development versions, such as the latest version of the author’s book: http://luajit.org/download/LuaJIT-2.1.0-beta1.tar.gz.
# wget http://luajit.org/download/LuaJIT-2.1.0-beta1.tar.gz
# tar -xvf LuaJIT-2.1.0-beta1.tar.gz
# cd LuaJIT-2.1.0-beta1
# make
# sudo make install
As you all know, there may be different installation tools on different platforms to simplify our installation. Why do we recommend source code in such a primitive way? Do I want to be lazy? Answer: Yes. Another reason, of course, is that we installed LuaJIT version 2.1.
From the performance of practical application, although LuaJIT 2.1 is still a beta version at present, its production and operation stability is very good, and its operation efficiency is much better than LuaJIT 2.0 (you can learn about it by yourself), so as the default partner of OpenResty, it has been LuaJIT 2.1 for a long time. However, for different system toolkit installation tools, their default binding presumption is still LuaJIT 2.0, so here is a direct way to give the most in line with our final direction of installation.
Verify that LuaJIT is installed successfully
# luajit -v
LuaJIT 2.1.0-beta1 -- Copyright (C) 2005-2015 Mike Pall.
http://luajit.org/
If you want to know the steps of installing LuaJIT on other systems, or if you encounter problems in the process of installing LuaJIT, you can visit the official website of LuaJIT: http://luajit.org/install.html.
The first “Hello World”
After installing LuaJIT, we started our first hello world applet. First, write a hello. Lua file. After writing the content, run it using LuaJIT.
# cat hello.lua
print("hello world")
# luajit hello.lua
hello world