I've read this and:
- There's no working solution proposed
- I'm not running Windows but Linux
- It's a home-made compilation
- running
httpd-2.4.9
So here's what I tried so far, but without success:
- follow this suggestion "where do I put 3rd party lua modules"?
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
- tried to put
lfs.so
in my lua shared /usr/local/share/lua/5.2
- tried to put
lfs.so
in the more generic shared /usr/local/share
- tried to put
lfs.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?