encyclopegia.org

Common Gateway Interface

In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program to process HTTP or HTTPS user requests.[src] Such programs are often written in a scripting language and are commonly referred to as CGI scripts, but they may include compiled programs.[src] A typical use case occurs when a web user submits a web form on a web page that uses CGI.[src] The form's data is sent to the web server within an HTTP request with a URL denoting a CGI script.[src] The web server then launches the CGI script in a new computer process, passing the form data to it.[src] The CGI script passes its output, usually in the form of HTML, to the Web server, and the server relays it back to the browser as its response to the browser's request.[src] Developed in the early 1990s, CGI was the earliest common method available that allowed a web page to be interactive.[src] Due to a necessity to run CGI scripts in a separate process every time the request comes in from a client, various alternatives were developed.[src]

In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program to process HTTP or HTTPS user requests.[src] Such programs are often written in a scripting language and are commonly referred to as CGI scripts, but they may include compiled programs.[src] A typical use case occurs when a web user submits a web form on a web page that uses CGI.[src] The form's data is sent to the web server within an HTTP request with a URL denoting a CGI script.[src] The web server then launches the CGI script in a new computer process, passing the form data to it.[src] The CGI script passes its output, usually in the form of HTML, to the Web server, and the server relays it back to the browser as its response to the browser's request.[src] Developed in the early 1990s, CGI was the earliest common method available that allowed a web page to be interactive.[src] Due to a necessity to run CGI scripts in a separate process every time the request comes in from a client, various alternatives were developed.[src] A Web server that supports CGI can be configured to interpret a URL that it serves as a reference to a CGI script.[src] A common convention is to have a cgi-bin/ directory at the base of the directory tree and treat all executable files within this directory (and no other, for security) as CGI scripts.[src] When a Web browser requests a URL that points to a file within the CGI directory (e.g., http://example.com/cgi-bin/printenv.pl/with/additional/path?and=a&query=string ), then, instead of simply sending that file ( /usr/local/apache/htdocs/cgi-bin/printenv.pl ) to the Web browser, the HTTP server runs the specified script and passes the output of the script to the Web browser.[src] That is, anything that the script sends to standard output is passed to the Web client instead of being shown in the terminal window that started the web server.[src] 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.[src] While convenient, and required by many prepackaged scripts, it opens the server to attack if a remote user can upload executable code with the proper extension.[src] The CGI specification defines how additional information passed with the request is passed to the script.[src] The Web server creates a subset of the environment variables passed to it and adds details pertinent to the HTTP environment.[src] For instance, if a slash and additional directory name(s) are appended to the URL immediately after the name of the script (in this example, /with/additional/path ), then that path is stored in the PATH_INFO environment variable before the script is called.[src] If parameters are sent to the script via an HTTP GET request (a question mark appended to the URL, followed by param=value pairs; in the example, ?and=a&query=string ), then those parameters are stored in the QUERY_STRING environment variable before the script is called.[src] Request HTTP message body, such as form parameters sent via an HTTP POST request, are passed to the script's standard input.[src] The script can then read these environment variables or data from standard input and adapt to the Web browser's request.[src]

28 sentences · 28 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Common Gateway Interface." encyclopegia.org, 2026, https://encyclopegia.org/wiki/common-gateway-interface. Accessed 27 November 2026.

Chicago

"Common Gateway Interface." encyclopegia.org. Accessed November 27, 2026. https://encyclopegia.org/wiki/common-gateway-interface.

APA

encyclopegia.org. (2026). Common Gateway Interface. Retrieved November 27, 2026, from https://encyclopegia.org/wiki/common-gateway-interface

Accessed November 27, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Border Gateway Protocol

stub · references available

Common Buttonquail

stub · references available

Common Moorhen

stub · references available

Common Murre

stub · references available

Common Nightingale

stub · references available

Common Pheasant

stub · references available

Common Kestrel

stub · references available

Common Redstart

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1378593462 · 0.5 · snapshot enwiki-001378593462

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.