Forum

Hiawatha + Perl CGIs

Dmitry
24 October 2005, 00:08
how to setup Perl CGI scripts in Hiawatha (v.3.6.1)?

script test.cgi:

#!/usr/bin/perl

print "Content-type: text/plain\n\n";
print "test\n";


httpd.conf:

...
CGIextension = cgi
ExecuteCGI = yes
TimeForCGI = 60
CGIhandler = /usr/bin/perl:cgi
...


always HTTP ERROR 500

I tried many combinations of directives with and without VirtualHost(s) in config file and more... but...

what's wrong?
Hugo Leisink
28 October 2005, 13:29
As specified in the HTTP RFC, a HTTP headerline should end with "\r\n", not with just "\n". Try the following CGI script:

#!/usr/bin/perl

print "Content-Type: text/plain\r\n\r\n";
print "It works!\n";



About your httpd.conf, CGIextension should not have a value that is also present in one of the CGIhandlers. With CGIhandler, Hiawatha runs the CGI handler program with the CGI script as the parameter. With CGIextension, Hiawatha just runs the CGI script, which can be any kind of program: a Perl script, a compiled C program, etc.

If you want Hiawatha to run a PHP script, you can configure Hiawatha in 2 ways:

The first one is:
...
CGIextension = php
ExecuteCGI = yes
...


This requires every PHP script to start with:
#!/usr/bin/php
<?
...


The preferable way to configure Hiawatha for PHP is:
...
CGIhandler = /usr/bin/php:php
ExecuteCGI = yes
...


You can know write (normal) PHP scripts that start like this:
<?
...


Hope this makes it all clear. If not, please let me know.
This topic has been closed.