Common Gateway Interface

In computing, Common Gateway Interface (CGI) offers a standard protocol for web servers to execute programs that execute like console applications (also called command-line interface programs) running on a server that generates web pages dynamically. Such programs are known as CGI scripts or simply as CGIs. The specifics of how the script is executed by the server are determined by the server. In the common case, a CGI script executes at the time a request is made and generates HTML.[1]

In brief, an HTTP GET request from the client will send the CGI program HTML form data via standard input. Other data, such as URL paths, and HTTP header data, are presented as process environment variables.


The official CGI logo from the spec announcement

In 1993 the National Center for Supercomputing Applications (NCSA) team wrote the specification for calling command line executables on the www-talk mailing list.[2][3][4] The other Web server developers adopted it, and it has been a standard for Web servers ever since. A work group chaired by Ken Coar started in November 1997 to get the NCSA definition of CGI more formally defined.[5] This work resulted in RFC 3875, which specified CGI Version 1.1. Specifically mentioned in the RFC are the following contributors:[1]

Historically CGI scripts were often written using the C language. RFC 3875 "The Common Gateway Interface (CGI)" partially defines CGI using C,[1] as in saying that environment variables "are accessed by the C library routine getenv() or variable environ".

Other Languages