I’m trying simple example –
#include <stdio.h>
int main(void)
{
printf("Content-type: text/html\n\n");
printf("<html><title>Hello</title><body>\n");
printf("Goodbye Cruel World\n");
printf("</body></html>");
return 1;
}
compiled and moved to apache docroot – but when i click on url – it comes as a popup and asks where to download/save this binary file? how to fix this?
Unfortunately, unless you already have other CGI scripts running in the same place, this is harder than just plopping a file somewhere – some stuff has to be configured in the web server to make it possible: apache settings, the
.htaccessfile, permissions, and so on.Make sure you read the Apache Tutorial on CGI to be up to date with what needs to be configured.