module Netcgi_mod:Apache "mod" connector.sig
..end
See the Setup section at the end of this file to know
how to configure Apache.
class type cgi =object
..end
cgi
class with an additional method to access Apache
specificities.
val run : ?config:Netcgi.config ->
?output_type:Netcgi.output_type ->
?arg_store:Netcgi.arg_store ->
?exn_handler:Netcgi.exn_handler -> (cgi -> unit) -> unit
run f
register the function f
as a main function of the
script. Each call to the script will execute f cgi
. The code
outside f
will be executed only once (when the script is
loaded into memory) which allows to cache database connections,
etc. (The code stays in memory unless you restart the server or
the file changes on disk.)config
: Default: Netcgi.default_config
output_type
: Default: `Direct ""
arg_store
: Default: `Automatic
for all arguments.exn_handler
: See Netcgi.exn_handler
. Default: delegate
all exceptions to the default handler.
In order to use the above function, you need to have mod_caml
installed (in fact, only partly, as we only use Apache
and
Mod_caml
-- and thus also Mod_caml_config
).
You need to put in Apache configuration file (e.g. in /etc/apache/conf.d/mod_caml) the following lines:
LoadModule caml_module /usr/lib/apache/1.3/mod_caml.so CamlLoad netstring/netsctring.cma CamlLoad netcgi/netcgi_mod.cmaOf course, you need to adapt the paths of necessary. The CamlLoad lines suppose that netcgi/ is a subdirectory of the default ocaml library location `ocamlc -where`, otherwise you need to use the full path.
You need also to tell Apache how to detect whether a script is to be handled by netcgi_mod, either by putting them in a special directory (here /caml-bin/):
Alias /caml-bin/ /path/to/your/scripts/ <Location /caml-bin> SetHandler ocaml-bytecode CamlHandler Netcgi_mod.handler Options ExecCGI Allow from all </Location>or by distinguishing them by their extension (here .cmo):
CamlHandler Netcgi_mod.handler AddHandler ocaml-bytecode .cmo