Netcgi Apache "mod" connector.
Netcgi_mod.setup section at the end of this file to know
how to configure Apache.
Interface to Apache API.
Registering Apache handlers.
cgi class with an additional method to access Apache
val run :
?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
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.)
`Automaticfor all arguments.
Netcgi.exn_handler. Default: delegate all exceptions to the default handler.
You need to put in an Apache configuration file (we recommend /etc/apache/conf.d/netcgi_apache.conf) the following lines:
LoadModule netcgi_module /usr/lib/apache/1.3/mod_netcgi_apache.so NetcgiRequire netcgi2-apache
You need to put in an Apache configuration file (we recommend /etc/apache2/mods-available/netcgi_apache.load) the following line:
LoadModule netcgi_module /usr/lib/apache2/modules/mod_netcgi_apache.so NetcgiRequire netcgi2-apache
and make a symbolic link from /etc/apache2/mods-enabled/ to it to actually enable it. Subsequent configuration is recommended to be in /etc/apache2/mods-available/netcgi_apache.conf (also to be linked to /etc/apache2/mods-enabled/).
If your scripts depend on other libraries, you need to load them
NetcgiLoad. More specifically, if your library is x.cma and
is in the subdirectory y of standard OCaml directory (given by
`ocamlc -where`), use
If x.cma is not in a subdirectory of `ocamlc -where`, you need to specify the full path.
Libraries managed with findlib are specially supported. In order to load a library "lib" just use
Findlib-managed libraries are automatically found.
For special configurations one can also set Findlib predicates:
If you need multi-threading call
as the very first directive after
LoadModule, even before
NetcgiRequire netcgi2-apache (otherwise a number of
critical sections remain unprotected in Ocamlnet, and you'll experience
You need also to tell Apache how to detect whether a script is to be handled by netcgi_apache, either by putting them in a special directory (here /caml-bin/):
Alias /caml-bin/ /path/to/your/scripts/ <Location /caml-bin> SetHandler ocaml-bytecode NetcgiHandler Netcgi_apache.bytecode Options ExecCGI Allow from all </Location>
or by distinguishing them by their extension (here
NetcgiHandler Netcgi_apache.bytecode AddHandler ocaml-bytecode .cma
If your script reside in the file
x.ml, compile it to
x.cma. If your script depends on other libraries, you may
either load them with
NetcgiLoad (see above) or include them in
x.cma. You need not include the
as these are already loaded into Apache (see above).