Web Hosting features: CGI

CGI (Common Gateway Interface) is the name given to a protocol that has become a standard for allowing an external set of application software to interface with a web server, used as an information server.

An information server, when used in this manner, has the task of providing or creating the responses for information within the framework of a web server when a client (web browser) requests information and the CGI application retrieves it, formats it and returns it top to the end user. By analyzing each request that a server gets form the users for information and analyzing the request, determining what is being asked for, retrieves it and formats the output, returning the appropriate information to service the request. There are two simple ways to perform such requests:

CGI is available on all of our UK web hosting packages for free, each web hoting account has its own personal and private CGI folder for your CGI scripts. For more info on our UK web hosting packages please click here.

The standard that is defined by CGI handles primarily the second type of request. CGI defines how the information about the request and the server it is going to is packaged with its arguments and variables defined in the environment along with how the command ot be executed can package the response in order to pass it back with any extra information describing the output including its type using a form of headers.

A wiki is one example for a CGI program that can be implemented. The command executing in the server as an agent takes a request for an entry in the wiki; the source of the entry is retrieved if it exists, translates it into a HTML page, sending back the resulting entry to the requesting user browser or allows one to be created if it didn’t exist in the server. This one program (CGI implementation of it) controls all operations on the wiki. If someone was trying to use a wiki on their own machine the server to respond to their own requests would be running on their own local machine and have a name of 'localhost'.

This whole process is handled based on the parameters passed to the CGI program; these parameters are passed as a part of the URL that directs the request to the appropriate webserver.

When the parameters are received at the web server, they are transformed into environment variables where they can be passed to the CGI program. Traditionally a program receives its parameters via command-line arguments. When HTTP PUT or POST commands are used, standard input is used to pass the data submitted by the user.

There is usually a directory on the web server at the root level that holds all the programs to be executed through the CGI protocol and it is usually called cgi-bin.

There are some drawbacks to this approach. The overhead that is required to support these commands being executed presents a burden on the server. Each command gets invoked as its own process and often that requires more processing than the command itself requires. It is possible to overwhelm a webserver with requests, making this approach non-optimal.

Several other approaches are becoming popular to address this situation, namely IIS ISAPI, SCGI and FastCGI.