Adventures with Lua 5.1 and Xavante 2.0 in Ubuntu 10.04

Get Installed

Assuming you already have Ubuntu 10.04 installed and running you can get Lua 5.1 and Xavante 2.0…

  • apt-get install lua5.1
  • apt-get install luarocks
  • luarocks install xavante
  • luarocks install wsapi-xavante

Installed rocks:

1.1.6-1 (installed) – /usr/local/lib/luarocks/rocks

1.13.0-1 (installed) – /usr/local/lib/luarocks/rocks

1.5.0-1 (installed) – /usr/local/lib/luarocks/rocks

2.0.2-3 (installed) – /usr/local/lib/luarocks/rocks

1.2.3-1 (installed) – /usr/local/lib/luarocks/rocks

1.3.4-1 (installed) – /usr/local/lib/luarocks/rocks

1.3.4-1 (installed) – /usr/local/lib/luarocks/rocks

2.2.0-1 (installed) – /usr/local/lib/luarocks/rocks

Now what ?

Assuming you have Xavante installed and ready to run you have to configure your Xavante Web Server.

Configure Xavante

mkdir /var/www2

Place the following file in a file named “xavante.lua”:

-- Sample Xavante configuration file for launching WSAPI applications.

require "xavante"
require "xavante.filehandler"
require "wsapi.xavante"

-- Define here where Xavante HTTP documents scripts are located
local webDir = "/var/www2/xavante"

local simplerules = {

 { -- URI remapping example
 match = "^[^%./]*/$",
 with = xavante.redirecthandler,
 params = {"index.html"}

 { -- URI remapping example
 match = "^[^%./]*/$",
 with = xavante.redirecthandler,
 params = {"index.lp"}

 { -- filehandler example
 match = ".",
 with = xavante.filehandler,
 params = {baseDir = webDir}

-- Displays a message in the console with the used ports
xavante.start_message(function (ports)
 local date ="[%Y-%m-%d %H:%M:%S]")
 print(string.format("%s Xavante started on port(s) %s",
 date, table.concat(ports, ", ")))

 server = {host = "*", port = 8080},
 defaultHost = {
 rules = simplerules


-- End Xavante configuration file for launching WSAPI applications.

This file allows your Xavante Web Server to run on port 8080.

Now you can install a “start” script to allow your Xavante Server to run.

Place the following script into a file called  “start” and chmod +x this file to make it executable:

wsapi -c xavante.conf -p 8080

Now make a folder called “xavante” as follows:

mkdir xavante

Now place an index file in the xavante folder with the name index.html.

Now run the start script and go to your browser and point it at port 8080 to see the index.html file display in your browser.

That’s All Folks

Now the trick will be to figure-out how to make Lua code jump into some “lp” files so you can begin to craft your Lua Powered web site.

Good Luck with that !

If you really love Lua to death and you don’t mind rolling-up your sleeves and dig-down deep within your soul you just might be able to craft a working Lua Powered site but… the level of effort will not be trivial and you may not get much help from the community at-large without some extra effort on your part.

There don’t seem to be a great number of people using Lua and Xavante for their web work and nowhere near as many as are working with Python/Django, for instance.

What’s the benefit of using Lua as a back-end language ?

Again, if you love Lua you don’t need to wonder about whether or not Lua should be used however the rest of us will likely not be using Lua to build our back-end servers.

I offer this information as a demo of how easily Lua can be installed in Ubuntu 10.04 – might take all of about 10 minutes for most people.  Once these steps have been followed you are left to wonder what to do next.  Good Luck with that…  You would be better served digging deep enough into Lua to allow you to craft your own Lua Web Server but then you might not achieve the level of robustness required to give you the confidence you need that your Lua powered Web Server will in-fact be usable by enough people at the same time.

It should be noted the index.html page timed-out when it was tested using the Apache ab.exe program as follows:

“C:\Apache228\bin\ab” -n 2000 -c 10 -v 1 -w -k http://ubuntu:8080/ > run-ab-xavante-1.html

For my installation the url “http://ubuntu:8080/” points to the index.html file I placed into my xavante folder and it does come-up in my browser when I test it using the Google Chrome Browser version 5.x.

The error message follows:

apr_poll: The timeout specified has expired (70007)

This is not the stuff that gives us confidence…

Enjoy !


About Ray C Horn
See my profile at with more than 1286+ connections and growing all the time.

Comments are closed.

%d bloggers like this: