September, 2017
12
Second blog post of our series dedicated to new languages, this time to Lua. If this language popularity in the web world remains low (compared to top dogs such as Python or Node.js), we want to show you that it is possible to host sites on a broad range of technologies.
Lua 5.1 to 5.3
On our previous post, we had explained that Node.js was becoming the fourth major language supported on alwaysdata. Lua, due to its lesser fame (for now), does not yet have that status. This, however, makes little difference:
- Versions 5.1, 5.2, and 5.3 are installed. You can select the version of your choice using the lua5.X command, for example, lua5.1. The lua command starts version 5.2 at the present time, but this may change in the future. It is thus better to specify the desired version.
- Luarocks (to install packages) and LuaJIT are also preinstalled.
Example: deploying a Sailor application
Let’s see how to deploy a web application with Lua using the Sailor framework. We need to install Sailor via SSH and then create our application:
1 2 3 4 5 | $ eval $(luarocks path --bin) $ luarocks --local install sailor $ sailor create hello $ cd hello $ nano start-server.lua |
We must edit the start-server.lua file to modify the line:
1 | server = {host = "*", port = 8080}, |
with:
1 | server = {host = os.getenv("IP"), port = os.getenv("PORT")}, |
Finally, in the alwaysdata administration, we must create a User program type site, with:
- command: lua5.1 ~/hello/start-server.lua
- working directory: hello
- environment: enter what the following command returns, via SSH: echo $(env | grep ^LUA_)
That’s it: our web application is now deployed.
The third post of our series will focus, for once, on a compiled language: Go!
no comments