I'm completly new to CGI and Apache but I'm trying out a few things. To start I wrote a simple hello CGI in C.
#include <stdio.h>
void main() {
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head><title>CGI Output</title></head>\n");
printf("<body>\n");
printf("<h1>Hello, world.</h1>\n") ;
printf("</body>\n");
printf("</html>\n");
}
compiled it gcc hello.c -o hello.cgi
and placed it in /var/www/mycgi
Afterward I modified httpd.conf to add the following
ScriptAlias /mycgi/ "/var/www/mycgi/"
in the IfModule alias_module and
<Directory "/var/www/mycgi">
Options +ExecCGI
AddHandler cgi-script .cgi
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
I have then restarted Apache and when I go to localhost/mycgi/hello.cgi the browser just downloads the file instead of running it. Help will be greatly apreciated!