4.3. Script Directives
ScriptAlias URLpath directory Server config, virtual host
The ScriptAlias directive converts requests for URLs starting with URLpath to execution of the CGI program found in directory. In other words, an incoming URL like URLpath/fred causes the program stored in directory/fred to run, and its output is returned to the client. Note that directory must be an absolute path. We recommend that this path be outside your webspace.
A cute feature of ScriptAlias is that it can allow a CGI to pretend to be a directory. If someone submits the URL URLpath/fred/some/where/else, then directory/fred is run, and /some/where/else is passed to it in the PATH_INFO environment variable. This can be used for all sorts of things, but one is worth mentioning: many browsers and caches detect CGIs by the presence of a question mark in the URL, and refuse to cache them. This gives a way of fooling them into caching. Of course, you should be sure you want them cached (or use cache control headers to prevent it, if that was not what you had in mind).
This directive is equivalent to ScriptAlias but makes use of standard regular expressions instead of simple prefix matching. The supplied regular expression is matched against the URL; if it matches, the server will substitute any parenthesized matches into the given string and use the result as a filename. For example, to activate the standard /cgi-bin, one might use the following:
ScriptAliasMatch ^/cgi-bin/(.*) /usr/local/apache/cgi-bin/$1
ScriptLog filename Default: no logging Resource config
Since debugging CGI scripts can be rather opaque, this directive allows you to choose a log file that shows what is happening with CGIs. However, once the scripts are working, disable logging, since it slows Apache down and offers the Bad Guys some tempting crannies.
ScriptLogLength number_of_bytes Default number_of_bytes: 10385760 Resource config
ScriptLogBuffer number_of_bytes Default number_of_bytes: 1024 Resource config
This directive specifies the maximum size in bytes for recording a POST request.
Scripts can go wild and monopolize system resources: this unhappy outcome can be controlled by three directives.
RLimitCPU # | 'max' [# | 'max'] Default: OS defaults Server config, virtual host
RLimitCPU takes one or two parameters. Each parameter may be a number or the word max, which invokes the system maximum, in seconds per process. The first parameter sets the soft resource limit, the second the hard limit.
RLimitMEM takes one or two parameters. Each parameter may be a number or the word max, which invokes the system maximum, in bytes of memory used per process. The first parameter sets the soft resource limit, the second the hard limit.
RLimitNPROC takes one or two parameters. Each parameter may be a number or the word max, which invokes the system maximum, in processes per user. The first parameter sets the soft resource limit, the second the hard limit.
Copyright © 2001 O'Reilly & Associates. All rights reserved.