Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
You can still use CGI with Apache. Apache will execute your program on each request and return its output from stdout as webserver response. If you have a form, it’ll get POSTed to stdin when Apache execute your program. You can write your program with whatever language you want as long as you can read stdin and write to stdout. It’s just tedious af so no one really use it these days.
You can’t use the CGI model with node and JS/Node because… unlike PHP, the thing isn’t designed for a quick start and shutdown.
Why not? Is it because a typical nodejs app include hundreds of npm dependencies? As long as it can launch and finish within 60s (default timeout for apache), you should be able to use it.
The point is that PHP is much more performant and doesn’t waste resources as NodeJS does. While you can run PHP on CGI with a decent bootstrap performance that won’t get people annoyed the same can’t be said of NodeJS. Nowadays people do PHP-FPM which is way faster at scaling up that any NodeJS process manager out there and doesn’t sit wasting resources when a particular application doesn’t have requests.
You can’t use the CGI model with node and JS/Node because… unlike PHP, the thing isn’t designed for a quick start and shutdown.
Why not? Is it because a typical nodejs app include hundreds of npm dependencies? As long as it can launch and finish within 60s (default timeout for apache), you should be able to use it.
Who wants to wait 60s for a website to load?
Not saying you should use CGI (who does these days), but saying you could still use it if you want
The point is that PHP is much more performant and doesn’t waste resources as NodeJS does. While you can run PHP on CGI with a decent bootstrap performance that won’t get people annoyed the same can’t be said of NodeJS. Nowadays people do PHP-FPM which is way faster at scaling up that any NodeJS process manager out there and doesn’t sit wasting resources when a particular application doesn’t have requests.