title: CGI won't run just download on Apache server
body: <p>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.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void main() {
      printf("Content-type: text/html\n\n");
      printf("&lt;html&gt;\n");
      printf("&lt;head&gt;&lt;title&gt;CGI Output&lt;/title&gt;&lt;/head&gt;\n");
      printf("&lt;body&gt;\n");
      printf("&lt;h1&gt;Hello, world.&lt;/h1&gt;\n") ;
      printf("&lt;/body&gt;\n");
      printf("&lt;/html&gt;\n"); 
  }
  </code></pre>
  
  <p>compiled it <code>gcc hello.c -o hello.cgi</code> and placed it in /var/www/mycgi</p>
  
  <p>Afterward I modified httpd.conf to add the following</p>
  
  <pre><code>ScriptAlias /mycgi/ "/var/www/mycgi/"
  </code></pre>
  
  <p>in the IfModule alias_module and </p>
  
  <pre><code>&lt;Directory "/var/www/mycgi"&gt;
      Options +ExecCGI
      AddHandler cgi-script .cgi
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>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!</p>