The Common Gateway Interface (CGI)

What is CGI?

What is CGI?

CGI is a simple protocol for generating dynamic web pages.

How does it work?

If I can simplify things a little bit, basically, CGI works like this:

  1. The web browser sends a request to the web server.
  2. The web server determines that the request is for a CGI program (and not a static web page).
  3. The web server executes the CGI program (passing it information about the request from the web browser).
  4. The CGI program processes the request and generates a response (usually this response is the dynamic web page).
  5. The web server captures the response from the CGI application, and sends that response back to the web browser.
That's It!

Well, that's almost it, a few questions need to be answered, like:

  • How does the web server know that a request is for a CGI program (and not a static web page)?
  • What kinds of information about the request, does the web server pass to the CGI program (and how is this information passed)?
  • How does the web server capture the response from the CGI program?

You can find out the answers to those questions (and more) at: