Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is cgi dead? [closed]

Tags:

apache

cgi

Ok, let's put it in a more mildly: Is cgi (common gateway interface) legacy?

yes? no?

Under what circumstances would a project starting today (one that does noot have to interact with legacy systems or libraries) use cgi?

like image 309
flybywire Avatar asked Sep 23 '09 08:09

flybywire


People also ask

Is CGI still in use?

common gateway interface (CGI), a standard that allows external applications located on personal computers or other devices to interact with information servers on the Internet. Developed in the 1990s, CGI is still used, but other methods such as PHP scripts are also utilized.

Why is CGI obsolete?

You compile the executable once, the webserver executes the program and passes the data in the request to the program and outputs the received response. CGI specifies that one program instance will be launched per each request. This is why CGI is inefficient and kind of obsolete nowadays.


2 Answers

It's far from dead actually. Despite the overheads, many virtual web hosting companies are now running PHP as CGI for security considerations, because it can be used with suEXEC. suEXEC means that your scripts execute under your actual Unix user privileges, and thus are restricted by the operating system's privilege separation. This is a much more robust security model than the PHP-specific open_basedir alternative.

Also, CGI is a really simple and quite versatile interface, support for it is never going out from web servers. Many newer interfaces like FastCGI and SCGI inherit the way that CGI passes HTTP headers and other variables to the web application and back. Even PHP's SAPI mimics this with its $_SERVER variable. So CGI is not going away, it is just being built upon.

like image 76
intgr Avatar answered Oct 11 '22 05:10

intgr


Legacy? Absolutely. Dead? Well, it's on life support. I doubt it will really "die" in the forseeable future. You might still use CGI to write a very small sort of script if you've got a server with no other means of running a webapp and you're too lazy to configure it up.

What's another reason? Maybe you've got a program that leaks memory or resources like a sieve but you need to run it anyway, so you make sure everything is cleaned up by ending the process every single request...

But seriously, for things that really matter, I think the benefits of moving to any sort of system with persistent processes outweigh the costs by quite a bit. And in my experience, it encourages writing better-organized code as well, because the kind of initialization you need to have a nicely modular application translates to "unacceptable startup time" in a CGI environment.

like image 23
hobbs Avatar answered Oct 11 '22 05:10

hobbs