The recommended way to have a web-server run a Kawa program as a CGI script is to compile the Kawa program to a servlet (as explained in Writing web-server-side Kawa scripts, and then use Kawa's supplied CGI-to-servlet bridge.
First, compile your program to one or more class files as explain in Writing web-server-side Kawa scripts. For example:
kawa --servlet --xquery -C hello.xql
Then copy the resulting .class
files to your server's
CGI directory. On Red Hat GNU/Linux, you can do the following (as root):
cp hello*.class /var/www/cgi-bin/
Next find the cgi-servlet
program that Kawa builds and installs.
If you installed Kawa in the default place, it will be in
/usr/local/bin/cgi-servlet
.
(You'll have this if you installed Kawa from source, but not
if you're just using Kawa .jar
file.)
Copy this program into the same CGI directory:
cp /usr/local/bin/cgi-servlet /var/www/cgi-bin/
You can link instead of copying:
ln -s /usr/local/bin/cgi-servlet /var/www/cgi-bin/
However, because of security issues this may not work, so it is
safer to copy the file. However, if you already have a copy
of cgi-servlet
in the CGI-directory, it is safe to make
a hard link instead of making an extra copy.
Make sure the files have the correct permissions:
chmod a+r /var/www/cgi-bin/hello*.class /var/www/cgi-bin/hello chmod a+x /var/www/cgi-bin/hello
Now you should be able to run the Kawa program, using the URL http://localhost/cgi-bin/hello. It may take a few seconds to get the reply, mainly because of the start-up time of the Java VM. That is why servlets are preferred. Using the CGI interface can still be useful for testing or when you can't run servlets. We hope to soon be able to run Kawa CGI scripts compiled using GCJ, which should have much reduced start-up time, making Kawa servlets more practical.