|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
The following, then, are the broad steps of the CGI process, simplified for clarity:
Its a bit more complicated than a normal HTML retrieval, but thats essentially how CGI works. The scripts become extensions to the servers repertoire of static files and open up the possibilities for real-time interactivity. Where CGI Scripts LiveLike any other file on a server, CGI scripts have to live somewhere. Depending on your server, CGI scripts may have to live in one special directory. Other servers let you put scripts anywhere you want. Typicallywhether required by the server or notWebmasters put all the scripts in one place. This directory is usually part of the Web servers tree, often just one level beneath the Web servers root. By far, the most common directory name is cgi-bin, a tradition started by the earliest servers that supported CGI. UNIX hacks will like the bin part, but because the files are rarely named *.bin and often arent in binary format anyway, the rest of the world rolls its eyes and shrugs. Today, servers usually enable you to specify the name of the directory and often support multiple CGI directories for multiple virtual servers (that is, one physical server that pretends to be many different ones, each with its own directory tree). Suppose that your UNIX Web server is installed so that the fully qualified path name is /usr/bin/https/webroot. The cgi-bin directory would then be /usr/bin/https/webroot/cgi-bin. Thats where you, as Webmaster, put the files. From the Web servers point of view, /usr/bin/https/webroot is the directory trees root. So if a file in that directory is named index.html, youd refer to that file with an /index.html URL. A script called myscript.pl in the cgi-bin directory would be referred to as /cgi-bin/myscript.pl. On a Windows or Windows NT server, much the same thing happens. The server might be installed in C:\Winnt35\System32\Https, with a server root of D:\Webroot. Youd refer to the file Default.htm in the server root as /Default.htm; never mind that its real location is D:\Webroot\Default.htm. If your CGI directory is D:\Webroot\Scripts, youd refer to a script called Myscript.exe as /Scripts/Myscript.exe.
For the sake of simplicity, assume that your server is configured to look for all CGI scripts in one spot and that youve named that spot cgi-bin off the server root. If your server isnt configured that way, you might want to consider changing it. For one thing, in both UNIX and Windows NT, you can control the security better if all executables are in one place (by giving the server process execute privileges only in that directory). Also, with most servers, you can specify that scripts may run only if theyre found in the cgi-bin directory. This enables you to keep rogue users from executing anything they want from directories under their control. CGI Server RequirementsCGI scripts, by their very nature, place an extra burden on the Web server. Theyre separate programs, which means the server process must spawn a new task for every CGI script thats executed. The server cant just launch your program and then sit around waiting for the response; chances are good that others are asking for URLs in the meantime. So the new task must operate asynchronously, and the server has to monitor the task to see when its done.
Does this mean you should shy away from running CGI scripts? Not at all. It just means you have to know your servers capacity, plan your site, and monitor performance on an ongoing basis. No one can tell you to buy a certain amount of RAM or to allocate a specific amount of disk space. Those requirements will vary based on what server software you run, what CGI scripts you use, and what kind of traffic your server sees. However, following are some general rules for several operating systems that you can use as a starting point when planning your site. Windows NTThe best present you can buy your Windows NT machine is more memory. Although a Windows NT Server runs with 12MB of RAM, it doesnt run well until it has 16MB and doesnt shine until it has 32MB64MB. Adding RAM beyond 64MB probably wont make much difference unless youre running a few very hungry applicationsfor example, database applications such as Access or SQL Server. If you give your server 32MB of fast RAM, a generous swap file, and a fast disk, it can handle a dozen simultaneous CGI scripts without sweating or producing a noticeable delay in response. In most circumstances, it also helps to change Windows NT Servers memory management optimization from the default Maximize Throughput for File Sharing to Balance. This tells Windows NT to keep fewer files in cache, so more RAM is immediately available for processes.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |