CGI (Common Gateway Interface)

botond published Jan. 2018, 09, 26:21 p.m. time

The Common Gateway Interface (CGI) is a protocol standard that provides a connection between web server software and server-side scripts, mostly on web servers, that allow web pages to be generated dynamically. These scripts are also called CGI scripts or server-side scripts. These can be, for example PHP, Perl, Python, or C programming languages.

When the client requests such a file from the server, such as entering a dynamic web store, a CGI connection is established, the server runs the requested script, and then returns its output to the client in compiled HTML form, which the browser displays.

Every web server runs some kind of HTTP server software, most often the Apache web server. The purpose of this software is to find the appropriate files on the server based on requests from the Internet and serve them to the requester. These files can be static files, such as index.html, but can also be dynamic files, such as index.php. In the latter case, the web server software uses CGI to connect to the processing environment running the file - in the case of index.php, to the PHP processor - which runs the file and then passes the resulting output to the web server. The web server then generates the appropriate content from it, which it sends back to the client's browser.

CGI scripts can even be embedded in static files in the form of smaller codes, so they only generate the appropriate parts of the webpage dynamically, while the rest of the page remains static.

Due to the rapid spread of the Internet, the number of users multiplied, so this standard became obsolete as each CGI request started a separate process on the server, which was a time-consuming and memory-intensive operation. Thus, if a website was visited by many visitors at once, the server was easily overloaded. Therefore, over time, the FastCGI standard, which could handle multiple hits at once.