CGI
acronymKept in this browser · My desk
Stands for: Common Gateway Interface
Common Gateway Interface: the convention, documented as CGI/1.1 in RFC 3875, by which a web server runs an external program for a request and returns what it prints.
The server passes the request as environment variables such as REQUEST_METHOD, SCRIPT_NAME, PATH_INFO and QUERY_STRING and the body on standard input; the program writes headers and a body to standard output. Conventional CGI starts a process per request, the cost FastCGI was designed to remove. PHP began in 1994 as a set of CGI binaries.
RFC 3875, published in October 2004 by D. Robinson and K. Coar of the Apache Software Foundation as an Informational document, records the "current practice" of the CGI/1.1 interface developed at NCSA and in use on the web since 1993. It leaves the mapping from a request URI to a script to the server, and defines PATH_INFO as the part of the path that follows the part identifying the script.
That split between the script and the path information is what PHP's cgi.fix_pathinfo setting and the web servers' path-splitting directives deal with, and the PHP manual's NGINX guide sets cgi.fix_pathinfo to 0 as its way of keeping requests for files that do not exist from reaching PHP-FPM. PHP still ships a CGI binary, php-cgi, and its manual calls cgi.force_redirect necessary for security when PHP runs as a CGI under most web servers.
Also known as: common gateway interface, cgi/1.1, rfc 3875, cgi-bin, php-cgi, path_info
Sources
- RFC 3875, The Common Gateway Interface (CGI) Version 1.1, October 2004: abstract, sections 3.3, 4.1.5 and 4.1.13 (read 2026-10-27)
- PHP Manual, History of PHP: PHP Tools as a set of CGI binaries written in C (read 2026-10-27)
- PHP Manual, Nginx 1.4.x on Unix systems: cgi.fix_pathinfo set to 0 (read 2026-10-27)
- PHP Manual, Description of core php.ini directives: cgi.fix_pathinfo and cgi.force_redirect (read 2026-10-27)