Xavante
A Lua Web Server with CGILua support

Installing

The default directory structure for Xavante is based on two directories:

  $XAVANTE_BIN  -- Lua and binary libraries, xavante_start.lua
    /cgilua
    /coxpcall
    /socket
    /xavante    -- Xavante Lua files

  $XAVANTE_WEB  -- Xavante default HTTP documents
    /doc        -- Xavante documentation
    /img        -- test images

The distributed source of Xavante can be copied to the $XAVANTE_BIN directory together with Lua and the other binary libraries.

The file t_xavante_start.lua is a template for the startup file. You must redefine it to something like the example below and then rename it to xavante_start.lua.

-- xavante_start.lua configured for a Windows installation
-- based on the C:\xavante directory

-- Library extension for the platform used
local LIB_EXT      = [[.dll]]

-- Physical location of Xavante file structure.
-- The example structure assumes that the bin
-- and web directories are under the same directory
local XAVANTE_HOME = [[C:/Xavante]]
local XAVANTE_BIN  = XAVANTE_HOME..[[/bin]]
local XAVANTE_WEB  = XAVANTE_HOME..[[/web]]

-- compatibility code for Lua version 5.0 providing
-- 5.1 behavior
if string.find (_VERSION, "Lua 5.0") and not package then
	if not LUA_PATH then
		LUA_PATH = XAVANTE_BIN.."/?.lua;"..
                   XAVANTE_BIN.."/?/?.lua"
	end
	require"compat-5.1"
	package.cpath = XAVANTE_BIN.."/?"..LIB_EXT..";"..
	                XAVANTE_BIN.."/lib?"..LIB_EXT
end

require "xavante.server"

xavante.setwebdir(XAVANTE_WEB)

-- Loads the configuration file and starts Xavante
xavante.start()

Configuring

The file $XAVANTE_BIN/xavante/config.lua defines the Xavante configuration. Xavante defines virtualhosts for each site that it is running. Each virtualhost can define a set of rules for it. Each rule matches a URL pattern with a handler. Xavante currently offers a file handler, a redirect handler and a CGILua handler for general files, URL remapping and CGILua scripts.

A tipical config.lua uses the format below

require "xavante.filehandler"
require "xavante.cgiluahandler"
require "xavante.redirecthandler"

local simplerules = {

    -- URL remapping example
    { match = "/",
      with = xavante.redirecthandler,
      params = {"/index.lp"}}, 
    
    -- filehandler example
    { match = "/*",
      with = xavante.filehandler,
      params = {baseDir = xavante.webdir()}},

    -- cgiluahandler example
    { match = {"/*.lp", "/*.lua"},
      with = xavante.cgiluahandler.makeHandler (xavante.webdir())},
}

xavante.HTTP{
    server = {host = "*", port = 80},
    
    defaultHost = {
    	rules = simplerules
    },
}

To use virtual hosts with Xavante, the call to xavante.HTTP would be changed to something like

xavante.HTTP{
    server = {host = "*", port = 80},
    
    defaultHost = {},
    
    virtualhosts = {
        ["www.sitename.com"] = simplerules
    }
}

Running

Running Xavante requires the execution of the correctly set xavante_start.lua. This can be done through a .bat file in Windows, or by giving execution rights to the xavante_start.lua on Linux.

Remember that xavante_start.lua is the configured version of t_xavante_start.lua and if you are installing Xavante from the source files you should edit it first.

After calling xavante_start.lua, opening the URL http://localhost on your browser should show the Xavante welcome page. If you changed the port number on config.lua you should also use this port number in the URL.

Valid XHTML 1.0!

$Id: manual.html,v 1.4 2005/03/16 20:22:30 carregal Exp $