CGI Programming on the World Wide WebBy Shishir Gundavaram1st Edition March 1996 This book is out of print, but it has been made available online through the O'Reilly Open Books Project. |
5.2 Configuration
How does the server know which files to parse, and which ones to return without parsing? From the information in the server configuration files, of course. Let's look at how we can configure SSI on the NCSA server.
The first thing you need to set is the extension(s) for the files that the server should parse in the server configuration file (srm.conf). For example, the following line will force the server to parse all files that end in .shtml:
AddType text/x-server-parsed-html .shtmlInternally, the server uses the text/x-server-parsed-html MIME content type to identify parsed documents. An important thing to note here is that you cannot have SSI directives within your CGI program, because the server does not parse the output generated by the program.
Alternatively, you can set the configuration so that the server parses all HTML documents:
AddType text/x-server-parsed-html .htmlHowever, this is not a good idea! It will severely degrade system performance because the server has to parse all the HTML documents that it returns.
Now let's look at the two configuration options that you must set in the access configuration file (access.conf) that dictate what type of SSI directives you can place in your HTML document:
- If you want to embed SSI directives to display the environment variables and file statistics in your HTML documents, you need to enable a feature called Includes.
- If you want to have the ability to execute external programs (CGI as well as other system applications) from within your HTML documents, you need to enable the Exec feature.
Here is how you would enable both Includes and Exec:
Options Includes ExecCGITo exclusively enable Includes without Exec, you need to add the following:
Options IncludesNoExecBefore enabling either of these features, you should think about system security and performance.
Configuring SSI for the CERN Server
As we mentioned at the beginning of this chapter, not all servers support SSI. However, you can use a Perl program called fakessi.pl to emulate SSI behavior.
For example, on the CERN server, all you need to do is:
- Install fakessi.pl into the cgi-bin directory.
- Add the following directive to httpd.conf:
Exec /*.shtml /usr/local/etc/httpd/cgi-bin/fakessi.pl(assuming that /usr/local/etc/httpd/cgi-bin is the directory that fakessi.pl was installed into).
This tells the server to execute fakessi.pl whenever a client requests a file ending in .shtml.
You can get fakessi.pl from http://sw.cse.bris.ac.uk/WebTools/fakessi.html.
Back to: CGI Programming on the World Wide Web
© 2001, O'Reilly & Associates, Inc.