|
Hi,
I don't *ever* mess with Xavante directly like that. I use the launcher (wsapi or orbit) installed during the wsapi-xavante rock. Just supply '.' for current working directory, or where ever your website source is (e.g. /var/xavante/<app-files>).
Have you read the Orbit docs (http://keplerproject.github.io/orbit/example.html). There is a good tutorial and it shows how the pieces fit together.
If you are looking for an alternative that does run its own webserver I suggest looking at Turbo.lua (http://turbolua.org).
--
Regards,
Ryan
Sent from my phone
Reading the Xavante manual, I found a suggestion of a configuration file:
--server.lua
local hfile = require "xavante.filehandler"
local hcgi = require "xavante.cgiluahandler"
local hredir = require "xavante.redirecthandler"
local xavante = require "xavante"
-- Define here where Xavante HTTP documents scripts are located
local webDir = XAVANTE_WEB
local simplerules = {
{ -- URI remapping example
match = "^[^%./]*/$",
with = hredir,
params = {"index.lp"}
},
{ -- cgiluahandler example
match = {"%.lp$", "%.lp/.*$", "%.lua$", "%.lua/.*$" },
with = hcgi.makeHandler (webDir)
},
{ -- filehandler example
match = ".",
with = hfile,
params = {baseDir = webDir}
},
}
xavante.HTTP{
server = {host = "*", port = 8080},
defaultHost = {
rules = simplerules
},
}
Note the use of webDir both to set the base directory for the file
handler and for the CGILua scripts. These paths should contain the
desired directories in your structure.
To use virtual hosts with Xavante, the call to xavante.HTTP would be
changed to something like
xavante.HTTP{
server = {host = "*", port = 8080},
defaultHost = {},
virtualhosts = {
["www.sitename.com"] = simplerules
}
}
It's not so easy to understand. I imagine "match" is used as the
rewrite rules of Apache.
XAVANTE_WEB seems to be a constant, probably "/", the current
directory where "server.lua" is placed.
I don't understand exactly the sense of cgiluahandler and filehandler.
But the most obscure part of the manual is about "xavante.start". If I
am using Xavante as a module, so I should call "xavante.start"
passing a "chck function".
I am using as a module? I am not sure! But as I have a
"require('xavante')", I believe yes.
"Check function"? the manual does not present an example... I don't
have any ideia what it is.
It would be wonderful if Xavante came with a standard configuration.
In PHP, with a simple "php --runserver", the server is raised.
As long as the time goes by, the experience increases and all the
parameters of the server will be understood. But at the first time,
it's really very complex!
2015-09-26 13:21 GMT-03:00, luciano de souza <luchyanus@gmail.com>:
> I had already installed Xavante. As I didn't know how Orbit works, I
> imagined it internally called Xavante. So I imagined an embeded
> server.
>
> This things are still confused for me. I found a brief tip of Xavante.
> It descrives the configuration, but I could not understand how to run
> it and where to place the files.
>
> Well, I am better than I was.
> 2015-09-26 12:39 GMT-03:00, Ryan Pusztai <rpusztai@gmail.com>:
>> You need a web server. Just running the app doesn't work. You need to use
>> apache2 (https://luanova.org/setting-orbit-to-use-apache2/) or Xavante
>> (luarocks install wsapi-xavante).
>>
>> I highly recommend Xavante. It installs easily and then you just run `$
>> wsapi app.lua`. I believe it defaults to port 8080. See the help on
>> `wsapi
>> --help` for more details.
>>
>> (I am not in front of a PC right now so some of the commands might be off
>> by a little bit.)
>>
>> Hope this helps.
>> --
>> Regards,
>> Ryan
>>
>> Sent from my phone
>> Coming back to Lua 5.1, the error disappear. But, I was not able to
>> launch the script! It seems to be very close.
>>
>> No errors, but no results. Doing "$ lua app.lua" at the terminal,
>> nothing is writen, not is returned...
>>
>> But, actually, I didnt no either what URL to call! What'is the port?
>> Sould I call as "localhost:3000"?
>>
>> The module is:
>>
>> -- hello.lua
>> #!/usr/bin/env wsapi.cgi
>>
>> local orbit = require('orbit')
>>
>> module('hello', package.seeall, orbit.new)
>>
>> function index(web)
>> return render_index()
>> end
>>
>> hello:dispatch_get(index, '/index')
>>
>> function render_index()
>> return [[
>> <html>
>> <title>Hello world</title>
>> <body>
>> <P> This is a hello world page</p>
>> </body>
>> </html>]]
>> end
>>
>> orbit.htmlify(hello, "render_.+")
>>
>> return M
>>
>> The launcher is:
>> #!/usr/bin/env wsapi.cgi
>>
>> return require('hello')
>>
>>
>>
>> 2015-09-26 11:10 GMT-03:00, Ryan Pusztai <rpusztai@gmail.com>:
>>> Orbit only supports Lua 5.1. Hope this helps.
>>> --
>>> Regards,
>>> Ryan
>>>
>>> Sent from my phone
>>> On Sep 26, 2015 9:38 AM, "luciano de souza" <luchyanus@gmail.com> wrote:
>>>
>>>> Hello all,
>>>>
>>>> I tried to run an example of Orbit application. I have a very short
>>>> knowledge about web servers, so I try to follow the tips I have found.
>>>>
>>>> First of all, I have installed everything:
>>>>
>>>> $ sudo apt-get install lua5.2
>>>> $ cd /home/luciano/Downloads/luarocks
>>>> $ sudo chmod +x configure
>>>> $ sudo ./configure
>>>> $ sudo make build
>>>> $ sudo make install
>>>> $ sudo make bootstrapp
>>>> $ sudo luarocks install orbit
>>>> $ sudo luarocks install xavante
>>>> $ sudo luarocks install wsapi-xavante
>>>>
>>>> So I regard this example:
>>>>
>>>> -- x.lua
>>>> #!/usr/bin/env wsapi.cgi
>>>>
>>>> local orbit = require('orbit')
>>>>
>>>> module('hello', package.seeall, orbit.new)
>>>>
>>>> function index(web)
>>>> return Render_Index()
>>>> end
>>>>
>>>> hello:dispatch_get(index, '/index')
>>>>
>>>> function Render_Index()
>>>> return [[
>>>> <html>
>>>> <title>Um teste</title>
>>>> <body>
>>>> <P> Eis aqui um teste. </p>
>>>> </body>
>>>> </html>]]
>>>> end
>>>>
>>>> orbit.htmlify(hello, "render_.+")
>>>>
>>>> return M
>>>>
>>>> I run:
>>>> $ lua x.lua
>>>>
>>>> and I got this error:
>>>>
>>>> lua: /usr/local/share/lua/5.2/orbit.lua:9: attempt to call local
>>>> 'setfenv' (a nil value)
>>>> stack traceback:
>>>> /usr/local/share/lua/5.2/orbit.lua:9: in main chunk
>>>> [C]: in function 'require'
>>>> x.lua:3: in main chunk
>>>> [C]: in ?
>>>>
>>>> What's wrong?
>>>>
>>>> In fact, my few knowledges can't detect the error.
>>>>
>>>> I thanky you very much for any help.
>>>>
>>>> Best regards,
>>>>
>>>>
>>>> --
>>>> Luciano de Souza
>>>>
>>>>
>>>
>>
>>
>> --
>> Luciano de Souza
>>
>
>
> --
> Luciano de Souza
>
--
Luciano de Souza