The Apache Haus Forum

Forum Topics => Apache 2.4 => Topic started by: mario on November 27, 2010, 09:08:12 PM

Title: mod_lua
Post by: mario on November 27, 2010, 09:08:12 PM
Today I tried to use mod_lua

in httpd.conf

LoadModule lua_module modules/mod_lua.so
AddHandler lua-script .lua


I putted the example.lua into my htdocs folder. But than I get a 500 error.


[Sat Nov 27 20:57:20.544939 2010] [lua:crit] [pid 1424:tid 616] [client 127.0.0.1:50542] lua: Unable to find function handle in C:/Apache2x/htdocs/example.lua, referer: http://localhost/


How to use mod_lua ??
Title: Re: mod_lua
Post by: Gregg on November 27, 2010, 11:08:40 PM
Hi Mario,

I've been to busy with everything else to even begin to think about looking at that module. Considering I have never seen any LUA code, I'm not sure where to begin. However, now that there is a docs page for it, it looks interesting.
Title: Re: mod_lua
Post by: Gregg on November 28, 2010, 08:28:13 PM
It does seem to work.

http://www.apachehaus.net/info.zip

try that script, outputs like phpinfo()
Title: Re: mod_lua
Post by: mario on November 29, 2010, 03:22:10 PM
Indeed that works. There is might an error in that other example. Now I have a new toy! Only need to learn lua :D
Title: Re: mod_lua
Post by: mario on November 29, 2010, 04:43:30 PM
my first working lua script.


function handle(r)
-- setup the environment
r.content_type = "text/html"
--r.headers_out["X-Powered-By"] = "mod_lua; " .. _VERSION
print = function(s) return r:write(tostring(s)) end

r:puts("Hi!")
print("Hi!")

-- finish
return apache2.OK
end


---- edit ---

every syntax error causing a 500 error is pretty anoying!
Title: Re: mod_lua
Post by: Gregg on November 29, 2010, 11:43:29 PM
Hi!Hi!

Welcome to my world, Perl does same  :D
Title: Re: mod_lua
Post by: mario on November 30, 2010, 10:19:31 AM
Does that code run unchaged on perl??
Title: Re: mod_lua
Post by: Gregg on November 30, 2010, 05:07:57 PM
no, I was just saying if you are writing in perl, the slightest syntax error will cause a 500.