CGI Scripting with Tengine
What's the big deal? All Web servers support CGI scripts, right? NO! Nginx and Tengine don't. Why? Well, because it's a horribly inefficient protocol. For every request, the web server must fire up a large external interpretter, the interpretter loads a script, the script is parsed, compiled, executed, and finally output is sent back to the web-server. Other systems reduce this to just sending the URL over a UNIX-domain socket to an interpretter that is already running and has likely already parsed and compiled the scripts. This is a huge benefit.
BUT! ... My php-fpm server only understands PHP. Its incredibly fast an efficient, but what if you have that one and only perl script or (shudder) a bash script? I would NOT recommend this hack on a production server due to security concerns. (Generally, don't use bash for CGI processing. Its a good hammer, but CGI isn't a nail.) But... here's one way to do it!
First a bit of magic in your server { } section of your web server config file :
Now, you need a wrapper called cgi-bin.php (in server root):
Now, assuming you have a /cgi-bin directory, you can run scripts like /cgi-bin/mycgi.cgi?h=45&y=6 or whatever. The script must be executable and must end in cgi and must be in the /cgi-bin directory.