I never really understood: what is CGI?
Posted
by claws
on Stack Overflow
See other posts from Stack Overflow
or by claws
Published on 2010-01-18T21:15:48Z
Indexed on
2010/03/26
18:33 UTC
Read the original article
Hit count: 484
CGI is a Comman Gateway Interface. As the name says, it is a "common" gateway interface for everything. It is so trivial and naive from the name. I feel that I understood this and I felt this every time I encountered this word. But frankly, I didn't. I'm still confused.
I am a PHP programmer. I did lot of web development.
user (client) request for page ---> webserver(->embedded PHP interpreter) ----> Server side(PHP) Script ---> MySQL Server.
Now say my PHP Script can fetch results from MySQL Server && MATLAB Server && Some other server.
So, now PHP Script is the CGI? because its interface for the between webserver & All other servers? I don't know. Sometimes they call CGI, a technology & othertimes they call CGI a program or someother server.
What exactly is CGI?
Whats the big deal with
/cgi-bin/*.cgi
? Whats up with this? I don't know what is thiscgi-bin
directory on the server for. I don't know why they have *.cgi extensions.Why does Perl always comes in the way. CGI & Perl (language). I also don't know whats up with these two. Almost all the time I keep hearing these two in combination "CGI & Perl". This book is another great example CGI Programming with Perl Why not "CGI Programming with PHP/JSP/ASP". I never saw such things.
CGI Programming in C this confuses me a lot. in C?? Seriously?? I don't know what to say. I"m just confused. "in C"?? This changes everything. Program needs to be compiled and executed. This entirely changes my view of web programming. When do I compile? How does the program gets executed (because it will be a machine code, so it must execute as a independent process). How does it communicate with the web server? IPC? and interfacing with all the servers (in my example MATLAB & MySQL) using socket programming? I'm lost!!
They say that CGI is depreciated. Its no more in use. Is it so? What is its latest update?
Once, I ran into a situation where I had to give HTTP PUT request access to web server (Apache HTTPD). Its a long back. So, as far as I remember this is what I did:
Edited the configuration file of Apache HTTPD to tell webserver to pass all HTTP PUT requests to some
put.php
( I had to write this PHP script)Implement put.php to handle the request (save the file to the location mentioned)
People said that I wrote a CGI Script. Seriously, I didn't have clue what they were talking about.
- Did I really write CGI Script?
I hope you understood what my confusion is. (Because I myself don't know where I'm confused). I request you guys to keep your answer as simple as possible. I really can't understand any fancy technical terminology. At least not in this case.
EDIT:
I found this amazing tutorial "CGI Programming Is Simple!" - CGI Tutorial Which explains the concepts in simplest possible way. I've only have one complaint about this tutorial. Just to make what ever he explained complete he should have shown the C code he used for generating response for those GET / POST requests. I've also added link to this tutorial to Wikipedia's article : http://en.wikipedia.org/wiki/Common_Gateway_Interface
© Stack Overflow or respective owner