How to run it

Jul 1, 2023    m. Apr 15, 2025

1. Online

You can try lua interactively .

4. System package

Before you should know that there is also LuaJIT project - a Just-In-Time Compiler for Lua. It can be used as a drop-in replacement for Lua.

On MacOS Lua can be installed with Homebrew:

brew update
brew install lua

Alternatively LuaJIT:

brew install luajit

On most Linux distributions Lua is available as lua and LuaJIT as luajit packages. On non-rolling distributions like Ubuntu it is preferable to install specific latest version, e.g. lua5.4.

Debian based:

sudo apt update && sudo apt install lua5.4 luajit

Arch Linux:

sudo pacman -Syu lua luajit

Fedora:

sudo dnf install lua
On Windows it can be installed either with luaforwindows project or luarocks all-in-one package.

2. Docker

Minimal docker image (~10MB):

Dockerfile

1FROM alpine:3.15.0
2
3RUN apk update \
4    && apk add --no-cache lua5.4
5
6WORKDIR /workdir
7
8ENTRYPOINT [ "lua5.4" ]

hello.lua

print("Hello, World!")

Build and run:

docker build -t lua .
docker run -v "$(pwd)":/workdir lua hello.lua

3. From source

Visit lua.org for detailed instructions to build Lua from source.



Next: Variables