From: http://www.5dlinux.com/article/9/2008/linux_16538.html
I use C language for CGI. Originally, CGI was required in an embedded system, which contains the Boa Server (configure the boa to support CGI in my next article ). First, learn to use CGI on a PC. The PC system is unbuntu7. 04.
First install The apache2 server.
# Sudo apt-Get install apache2
The configuration file directory is in/etc/apache2/sites-enabled/000-default.
# Vi/etc/apache2/sites-enabled/000-Default
Modify the following two sentences:
DocumentRoot/var/www/html
ScriptAlias/cgi-bin // var/www/html/cgi-bin/
DocumentRoot is followed by a directory containing HTML files. Access http: // 127.0.0.1 /???. HTML.
ScriptAlias is followed by/cgi-bin/to/var/www/html/cgi-bin /. Access 127.0.0.1/cgi-bin/??? in the browser /???.
You can set these two directories by yourself.
After the modification is completed, restart apache2.
#/Etc/init. d/apache2 restart
Note that the CGI program attribute must be set to run (755). If the directory of the CGI-related HTML file is to be written by the CGI program, the permission must be set to writable (666 ).
Now your cgi program can run.