Second blog post of our series ded­i­cat­ed to new lan­guages, this time to Lua. If this lan­guage pop­u­lar­i­ty in the web world remains low (com­pared to top dogs such as Python or Node.js), we want to show you that it is pos­si­ble to host sites on a broad range of tech­nolo­gies.

Lua 5.1 to 5.3

On our pre­vi­ous post, we had explained that Node.js was becom­ing the fourth major lan­guage sup­port­ed on always­da­ta. Lua, due to its less­er fame (for now), does not yet have that sta­tus. This, how­ev­er, makes lit­tle dif­fer­ence:

  • Versions 5.1, 5.2, and 5.3 are installed. You can select the ver­sion of your choice using the lua5.X com­mand, for exam­ple, lua5.1. The lua com­mand starts ver­sion 5.2 at the present time, but this may change in the future. It is thus bet­ter to spec­i­fy the desired ver­sion.
  • Luarocks (to install pack­ages) and LuaJIT are also pre­in­stalled.

Example: deploying a Sailor application

Let’s see how to deploy a web appli­ca­tion with Lua using the Sailor frame­work. We need to install Sailor via SSH and then cre­ate our appli­ca­tion:


We must edit the start-server.lua file to mod­i­fy the line:


with:


Finally, in the always­da­ta admin­is­tra­tion, we must cre­ate a User pro­gram type site, with:

  • com­mand: lua5.1 ~/hello/start-server.lua
  • work­ing direc­to­ry: hel­lo
  • envi­ron­ment: enter what the fol­low­ing com­mand returns, via SSH: echo $(env | grep ^LUA_)

That’s it: our web appli­ca­tion is now deployed.

The third post of our series will focus, for once, on a com­piled lan­guage: Go!