Common Gateway Interface (CGI) still alive?

Is CGI “obsolete” now?Typewriter

For CGI-Bin, there is a widespread misconception that CGI is “obsolete” now.
People who push this idea, don’t really understand what CGI is.

If you want to be a real technologist, you need to understand the fundamental issues and make a choice based on the facts of the situation.  The “obsolete”-ness of CGI is really only a factor if you are doing big, complex sites with lots of page views.


What is CGI ?

Common Gateway Interface (CGI) is a standard method used to generate dynamic content on Web pages and Web applications.

CGI runs on a Web server like APACHE. And it’s basically provides an interface between the Web server and programs that generate the Web content.

Programming languages or scripts, which are use to generate web contents  are known as CGI scripts or simply CGIs. These scripts can be written in PHP, PERL, C, JAVA.



CGI Architecture Diagram


CGI Architecture


APACHE Web Server Configuration for CGI

In order to configure CGI programs to work properly, you’ll need to have Apache configured to permit CGI execution. There are several ways to do this.

In my example, I will be using PERL as a CGI Script.

Configure httpd.conf for APAHCE:

In your Apache httpd.conf you need to make sure the LoadModule directive has not been commented out. A correctly configured directive may look like this:

LoadModule cgi_module modules/


The ScriptAlias directive tells Apache that a particular directory is set aside for CGI programs. Apache will assume that every file in this directory is a CGI program, and will attempt to execute it, when that particular resource is requested by a client.

The ScriptAlias directive looks like:

ScriptAlias   /cgi-bin/ /usr/local/apache2/cgi-bin/

Options to permit CGI execution

Use the Options directive to specify that CGI execution was permitted in a particular directory:

    Options +ExecCGI

And finally AddHandler directive tells the server to treat all files with the cgi or pl extension as CGI programs:

AddHandler cgi-script .cgi .pl

And finally it’s turn for testing. Hello World  CGI program

The following is an example CGI program that prints one line to your browser. Type in the following, save it to a file called and put it in your cgi-bin directory.

print "Content-type: text/html\n\n";
print "Hello, World."

Thats it for the configuration part and my view on misconception about CGI “obsolete”-ness.