Setup Cgi on Debian with Apache2

 1 /*********************************************************
 2 C Programming in Linux 
 3 demo.c
 4 *********************************************************/
 5 #include <stdio.h>
 6
 7 int main(int argc, char *argv[])
 8 {
 9     int i=0;
10     printf("Content-type:text/plain\n\n");
11     printf("Hello World!\n");
12     printf("Number of arguments to the main function:%d\n",argc);
13     for(i=0; i<argc; i++)
14     {
15         printf("argument number %d is %s\n", i, argv[i]);
16     }    
17     return 0;
18 }
gcc -o demo demo.c
sudo cp demp /usr/lib/cgi-bin
sudo a2enmod cgi
Enabling module cgi.
To activate the new configuration, you need to run:
  systemctl restart apache2
http://localhost/cgi-bin/demo
http://localhost/cgi-bin/demo?fname+lname