
A Simple LAMP Setup
|
123
comments that Apache interprets to echo the values of variables or include the con-
tents of other HTML files. SSI file inclusion is a simple way for a site to define a com-
mon header and footer for its pages, for instance.
SSI has its limits, though, and most dynamic sites use the far more powerful Common
Gateway Interface (CGI) programs. These executable programs can be written in any
language that Linux supports, although the most popular choices are dynamic (“script-
ing”) languages such as Perl, PHP, Python, and Ruby, followed by Java. CGI is a proto-
col that specifies how web clients and servers should exchange requests and responses.
When CGI first appeared on the Web, CGI programs were completely separate from
web servers. Each request caused the web server to start up a new CGI process. The
startup cost increased system load as sites got busier, so alternatives were developed.
People often confuse the CGI protocol with this early implementation method and
think that CGI is inherently slow. However, the CGI standard does not define imple-
mentation. There are faster methods that follow the same CGI protocol.
One faster method is FastCGI, which starts up the CGI program as a separate long-
running process and manages two-way communications between it and the web
server. This avoids the constant reload cost, and the process separation ensures that
if the CGI program ...