I am trying to configure the mod_lua module for Apache, but have encountered difficulties accessing third-party Lua modules. Let's say I have hello_world.lua in the Apache htdocs folder, which has something like this:
require "apache2" function handle(r) r.content_type = "text/html" r:write "Hello World from <strong>mod_lua</strong>." return apache2.OK end
And I go to "http: //localhost/hello_world.lua", which will function properly. But if I try to add a line, for example:
require "socket"
or
require "cgilua"
I get the following output:
Error!
try calling nil value
However, some modules work, for example:
require "base"
This works as expected.
If I go to base.lua on the file system (c: \ program files \ lua \ 5.1 \ lua \ base.lua) and delete this file and then try to run my script, I get the same error as above. Thus, it should be a directory that mod_lua checks for modules. The dll modules are not located in this folder, instead they are in the c: \ program \ lua \ 5.1 \ clibs \ directory, which I set for the LUA_CPATH environment variable.
Luasocket and cgilua are present in this folder, but they cause an error when I try to require them in my script.
From what I can compile, it works fine with any pure lua modules, but anything that has cmodules (socket, etc.) causes problems.
Additional Information:
What needs to be done to be able to require modules in scripts executed by mod_lua?
source share