CGI

Common Gateway Interface is a specification for web servers to interact with scripts or binaries. It launched a family of specifications, such as FastCGI and WSGI.


History

The Common Gateway Interface was designed to enable dynamic web pages without requiring web servers to be highly extensible. (In comparison, Apache had modules that enabled direct execution of scripts, such as mod_php and mod_perl.) The web server spawns a process to handle a request, passing information by the environment. By convention, CGI scripts are typically placed in a cgi-bin folder under the web root.

For a variety of performance and security reasons, CGI scripts are no longer used. FastCGI is a comprehensive upgrade of the specification that is still used. The most significant change is that spawned processes run continuously to handle multiple requests, rather than exiting upon completion of a single request. Communication between processes is handled by (TCP or Unix) sockets.

Language-specific frameworks have also emerged as a successor, such as Python's Web Server Gateway Interface.

In any case, a CGI program accesses system and connection information by way of environment variables, such as $DOCUMENT_ROOT (the web root), $SCRIPT_FILENAME (the CGI script's filename which should be under the web root), and $QUERY_STRING (the requested URI parameters).


FastCGI

Options for FastCGI servers include:


Web Server Gateway Interface

The Python project designed a succor specification called Web Server Gateway Interface, or WSGI. While there is a reference implementation (wsgiref), the following are far more commonly used:


CategoryRicottone

Protocols/CGI (last edited 2023-04-08 20:48:05 by DominicRicottone)