Forum

How to run CGI app on Windows version

Phillip
19 November 2012, 03:47
Hiawatha version: 8.6
Operating System: Windows

Hi,

I've updated the hiawatha.conf file:

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications. Use the 'php-fcgi'
# tool to start PHP as a FastCGI daemon.
#
#CGIhandler = C:\Program Files\PHP5\php-cgi.exe:php
CGIhandler = C:\Program Files\Hiawatha\bin\ssi-cgi.exe:shtml
CGIextension = cgi
#
#FastCGIserver {
# FastCGIid = PHP5
# ConnectTo = 127.0.0.1:2005
# Extension = php
#}

but I can't seem to get the Hiawatha web server to run a C compiled executable CGI file mentioned in the ACTION tag of the FORM html tag.

My browser opens up a dialog window with "Open with ..." and "Save" options for the specified CGI file.

Any suggestions?

Thanks.
Hugo Leisink
19 November 2012, 07:02
Does the executable have the extension .cgi?
Phillip
20 November 2012, 05:27
Yes. I can run the executable from a DOS Command Prompt window:

C:\Program Files\Hiawatha\bin>hello.cgi
Content-Type: text/plain

Hello World in C!

C:\Program Files\Hiawatha\bin>

Out of interest, I'm using Mozilla Firefox as the web browser.
Phillip
20 November 2012, 05:38
Hi, I've moved hello.cgi into c:\wwwroot\ but now get a 403 Forbidden HTTP error.
Phillip
20 November 2012, 05:44
The error log shows the same type of error with different timestamps:

192.168.0.66|Tue 20 Nov 2012 17:39:20 +1300|/cygdrive/c/wwwroot/hello.cgi|CGI execution not allowed
Hugo Leisink
20 November 2012, 07:08
Add ExecuteCGI = yes to the virtual host configuration. This is explained in the CGI an FastCGI HOWTO page...
Phillip
20 November 2012, 21:25
Thanks for the hint.

I've previously read the HOWTO: Using CGI and FastCGI page but didn't understand where the following setting

VirtualHost {
...
ExecuteCGI = yes
}

went. Now that I've read the HIAWATHA manual page and:

SECTIONS
The binding, directory, FastCGI, virtual host and URL toolkit configuration must be placed inside sections ...

I now understand.

In terms of making CGI work, I'm not currently using a virtual host so CGI still didn't work with the following:
# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications. Use the 'php-fcgi'
# tool to start PHP as a FastCGI daemon.
#
#CGIhandler = C:\Program Files\PHP5\php-cgi.exe:php
CGIhandler = C:\Program Files\Hiawatha\bin\ssi-cgi.exe:shtml
CGIextension = cgi

VirtualHost {
Hostname = 127.0.0.1
WebsiteRoot = C:\wwwroot
ExecuteCGI = yes
}

in hiawatha.conf.

However, CGI works after I added ExecuteCGI = yes to the Default Website settings in hiawatha.conf:
# DEFAULT WEBSITE
# It is wise to use your IP address as the hostname of the default website
# and give it a blank webpage. By doing so, automated webscanners won't find
# your possible vulnerable website.
#
Hostname = 127.0.0.1
WebsiteRoot = C:\wwwroot
StartFile = index.html
AccessLogfile = C:\Program Files\Hiawatha\log\access.log
ErrorLogfile = C:\Program Files\Hiawatha\log\error.log
ExecuteCGI = yes

Thanks for your prompt responses!
This topic has been closed.