Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is CGI and what are CGI Scripts? [closed]

Tags:

apache

cgi

Ive seen a folder called cgi-bin quite long while using apache.

How do scripts help me?

how can i use them?

I've used php and ajax only for web development!

like image 413
Dinesh Babu K G Avatar asked Jan 02 '10 02:01

Dinesh Babu K G


2 Answers

G'day,

A web server, e.g. Apache, just sends back static content is response to a client request for content. For example a request for http://www.myserver.com/index.html typically causes the server to open the file and return the content of the file wrapped with the relevant http components.

Basically CGI is a technique for generating such web pages dynamically via other applications which are run by the web server on an as-needed basis.

The directory cgi-bin is typically used to house the scripts being run.

Though it's heavily focused on Perl The book "CGI Programming with Perl" has an excellent intro about CGI.

Edit: As asked in the comments below, "if PHP can take care of dynamic content, then what's the need for CGI". There's a few points here.

  1. out of the box, PHP can be pretty slow. CGI, especially in its mod_perl guise, or when using app's built in compiled languages,
  2. PHP doesn't have very strong error handling, but this can be worked around,
  3. I don't think that there's real support for ASP, Windows app's or DB's, and
  4. PHP security is a bit of a worry, e.g. having register_globals enabled, and PHP's flaws are extremely well known.

The design of the PHP language itself also contains many inconsistencies, e.g.

  • a fairly useless object model,
  • scoping is fairly bad,
  • inconsistent naming, and
  • poor organisation of the standard library.

I believe that PHP5 goes a long way to improving these points.

While security is always a concern, with CGI implementations you are able to minimise the security problem in well publicised ways.

HTH

cheers,

like image 162
Rob Wells Avatar answered Oct 12 '22 23:10

Rob Wells


cgi-bin stands for CGI binary. To be honest, if you're acquainted with PHP already then you've likely little need for old-fashioned CGI scripts.

like image 27
Will Vousden Avatar answered Oct 12 '22 23:10

Will Vousden