Generating dynamic pages using CGI
Since the earliest days of the World Wide Web, it was possible to generate web pages dynamically using a standard method called the Common Gateway Interface (CGI). With the use of CGI, an Apache web server can generate dynamic content by executing any program installed on the same machine as long as that program generates the text of a properly formatted HTTP response. The main advantage of this method is its universality, as CGI scripts may be written in any programming language. In this recipe, we will demonstrate how to write a simple Hello World script in the shell scripting language, Bash, but the same principles would apply to any other programming language.
The main disadvantage of the CGI protocol is the fact that the web server must invoke a new process for each incoming request. This solution does not scale very well and is therefore applicable to low traffic sites only. The other disadvantage of using CGI directly is that the protocol is very...