More Details
A web server that supports CGI can be configured to interpret a URL that it serves as a reference to a CGI script. A common convention is to have a cgi-bin/ directory at the base of the directory tree and treat all executable files within it as CGI scripts. Another popular convention is to use filename extensions; for instance, if CGI scripts are consistently given the extension .cgi, the web server can be configured to interpret all such files as CGI scripts.
In the case of HTTP PUT or POSTs, the user-submitted data is provided to the program via the standard input. The web server creates a small and efficient subset of the environment variables passed to it and adds details pertinent to the execution of the program.
Read more about this topic: Common Gateway Interface