Install basement

$ sudo apt-get install apache2-mpm-worker liblua5.1-0-dev
$ sudo apt-get install libfcgi-dev libapache2-mod-fcgid

Install Luarocks

Download latest version from: http://luarocks.org/releases/, extract it, open a terminal and do a "cd" into its directory, then:

$ ./configure --with-lua-include=/usr/include/lua5.1/
$ make
$ sudo make install

Install WSAPI

$ sudo luarocks install wsapi-fcgi

Configure Apache

Edit /etc/apache2/sites-enabled/000-default, in section  "Directory var/www", set "AllowOverride" from "None" to "All"

$ sudo /etc/init.d/apache2 restart

Test

Create following files in /var/www/:

.htaccess:

Options ExecCGI
AddHandler fcgid-script .lua
FCGIWrapper /usr/local/bin/wsapi.fcgi .lua

launcher.fcgi:

#!/usr/bin/env lua

require "wsapi.fastcgi"
require "hello"
wsapi.fastcgi.run(hello.run)

index.lua

module(..., package.seeall)

function run(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }

  local function hello_text()
    coroutine.yield("<html><body>")
    coroutine.yield("<p>Hello Wsapi!</p>")
    coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
    coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
    coroutine.yield("</body></html>")
  end

  return 200, headers, coroutine.wrap(hello_text)
end

Go to http://localhost/hello.lua

Further reading

Blessings!