I've read this and:
httpd-2.4.9So here's what I tried so far, but without success:
tried to add all possibilities of PATH for Lua in my vhost conf:
LuaPackageCPath /web/htdocs/olivier/doonoo/2/
LuaPackagePath /web/htdocs/olivier/doonoo/2/
LuaPackageCPath /web/htdocs/olivier/doonoo/2
LuaPackagePath /web/htdocs/olivier/doonoo/2
LuaPackageCPath /web/htdocs/olivier/doonoo/2/?.so
LuaPackagePath /web/htdocs/olivier/doonoo/2/?.so
LuaPackageCPath /web/htdocs/olivier/doonoo/2/?
LuaPackagePath /web/htdocs/olivier/doonoo/2/?
LuaPackageCPath /web/htdocs/olivier/doonoo/2/
LuaPackagePath /web/htdocs/olivier/doonoo/2/
LuaPackageCPath ./?.so
LuaPackagePath ./?.so
LuaPackageCPath ./
LuaPackagePath ./
LuaPackageCPath ./?
LuaPackagePath ./?
tried to put lfs.so in my http folder: /local/install/httpd-2.4.9/modules/lua
lfs.so in my lua shared /usr/local/share/lua/5.2lfs.so in the more generic shared /usr/local/sharelfs.so in the shared http modules /opt/httpd-2.4.9/modules/And now I still haven't found a working solution. Any idea?
By the way I can use r:notice() to write some information, so is there a way to dump the path and/or cpath that lua is using?
In my files, when I have the directive require "bb" in the file aa.lua and bb.lua is in the same path as the aa.lua, it works. If I try to do export LUA_PATH= and restart my webserver, the directive require "bb" doesn't work anymore in aa.lua. This implies that the environment variable LUA_PATH and LUA_CPATH have some effect on the Apache mod_lua.
Now I tried something else: dynamic library. I do this:
# lua
Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> a,b = package.loadlib('/usr/local/lib/posix_c.so', 'fcntl')
> print (a,b)
function: 0x7fbda3f845b0 nil
>
This means it tried successfully to open + get the fcntl function coming from posix_c.so.
Now if I try to add this code into my lua file for mod_lua like this:
function handle(r)
r.headers_out['Cache-Control'] = 'no-cache, must-revalidate'
r.headers_out['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'
r.content_type = 'application/json';
local a,b = package.loadlib('/usr/local/lib/posix_c.so', 'fcntl');
r:puts(tostring(a)..','..tostring(b))
return apache2.OK
end
I got this output:
nil,/usr/local/lib/posix_c.so: undefined symbol: luaL_setfuncs
After reading this, I guessed what went wrong: I had installed 5.2.1 version and mod_lua was compiled with 5.1. So I removed the 5.2.1, all 5.2 links, and re-compiled the luaposix lib. Now the Webpage gives me this: function: 0x220bce0,nil which means it successfully opened the library.
Any idea what's going on?
I've made it!
Two things were blocking, and I hope to help other ones if they have the same problem:
mod_lua was 5.1 and lua installed was 5.2. Solution: remove 5.2 and install 5.1, then recompile all needed modules*.so location. This command helped me to solve the problem: r:puts(tostring(package.cpath) .. ',\n'). It shows the path where lua is looking for the dynamic libraries. And no one matched where my lfs.so, posix_c.so, and posix.lua were. Thus I've made the folder /usr/local/lib/lua/5.1/ (which is very "clean" name and location to me) and copied those files there.Now everything works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With