[ Pobierz całość w formacie PDF ]
.An idle process is one that is not handling a request.If there arefewer idle Apache processes than the number specified by the MinSpareServersdirective, then the parent process creates new children at a maximum rate of 1 persecond.Tuning of this parameter should only be necessary on very busy sites.Unless you know what you are doing, do not change the default.Syntax: MinSpareServers numberDefault setting: MinSpareServers 5Context: Server configPidFileSee PidFiledirective under the MPM threaded-Specific Directives section.ScoreBoardFileSee ScoreBoardFiledirective under the MPM threaded-Specific Directives section.SendBufferSizeSee SendBufferSizedirective under the MPM threaded-Specific Directives section.StartServersSee StartServersdirective under the MPM threaded-Specific Directives section.UserSee Userdirective under the MPM threaded-Specific Directives section.&' &' &'c4821-2 ch05.F 2/22/02 10:12 AM Page 105C H A P T E R55Apache Modules&' &' &' &'n Chapter 4, I discuss core and multiprocessing moduleIn This ChapterI(MPM) directives.Apache offers many more directives,which are available from the modules distributed in the stan-How to usedard source distribution.These modules offer a great deal ofenvironment modulesfunctionality via the use of directives.This chapter discussesthese modules and their directives.How to useauthentication andaccess controlmodulesAn Overview of the ModulesInstead of listing all the modules in alphabetic order, I haveHow to use dynamicgrouped modules based on their similarities in functionality.contents generationThe modules are divided into the following categories:modules&' Environment-related: These directives allow you to setHow to use directory-and reset environment variables.listing modules&' Authentication and access control: These directivesHow to use contentallow you to authenticate and authorize user access totype modulesrestricted parts of your Web site.&' Dynamic contents generation: These directives allowHow to use dynamicyou to run external programs such as CGI scripts orcontents generationServer Side Includes to create dynamic contents.modules&' Content-type configuration: These directives allow youto control MIME types of files.How to use responseheader modules&' Directory listing: These directives allow you to controlhow directory listings are formatted.How to use server&' Response header: These directives allow you to controlinformation andHTTP response headers.logging modules&' Server information and logging: These directives allowHow to use URL mapyou to control server logs and status information.modules&' URL mapping: These directives allow you to map,rewrite, and create aliases for a URL.How to use othermiscellaneous&' Miscellaneous modules: These directives allow you tomodulescontrol miscellaneous aspects of Apache such as proxyservice, WEBDEV module, etc.&' &' &' &'c4821-2 ch05.F 2/22/02 10:12 AM Page 106Part I &' Getting Started106Environment-Related ModulesThe modules listed in Table 5-1 enable you to manipulate the environment that isavailable to other modules or to external programs, such as CGI (Common GatewayInterface) scripts, SSI (Server-Side Include), mod_perlscripts, PHP scripts, Javaservlets, and the like.Table 5-1Environment-Related ModulesModule Purposemod_env Passes environments to external programs such as CGI and SSI scripts.mod_setenvif Sets conditional environment variables using information from theclient side.mod_unique_id This module generates a unique ID per request.It has no directives.This module is not compiled by default.You must configure the sourceby using --enable-unique-id option with the configure scriptand by compiling and installing Apache.mod_envmod_envis compiled by default.It enables you to pass environment variables toexternal programs such as CGI scripts, SSI, mod_perlscripts, PHP scripts, and thelike.mod-envhas the following directives.PassEnvThe PassEnvdirective tells the module to pass one or more environment variablesfrom the server s own environment to the CGI and SSI scripts.Syntax: PassEnv variable [.]Context: Server config, virtual hostFor example, the following directive passes the HOSTTYPE and PATH environmentvariables to programs.PassEnv HOSTTYPE PATHc4821-2 ch05.F 2/22/02 10:12 AM Page 107Chapter 5 &' The Apache Modules107SetEnvThe SetEnvdirective sets an environment variable to a given value, which is thenpassed on to CGI/SSI scripts.You can only define a single variable and value pairper SetEnvdirective.Syntax:SetEnv variable valueContext: Server config, virtual hostFor example, the following SetEnv directive sets the CURRENT_CITY variable toSACRAMENTO:SetEnv CURRENT_CITY SACRAMENTOUnsetEnvThe UnsetEnvdirective removes one or more environment variables from thosethat are passed to CGI/SSI scripts.This can be used to ensure that certain environ-ment variables that are available to the Apache server are not available to your CGIscripts.Syntax: UnsetEnv variable [.]Context: Server config, virtual hostFor example, the following UnsetEnvdirective removes the CURRENT_STATEvariable from the environment variable list:UnsetEnv CURRENT_STATEmod_setenvifThe mod_setenvifmodule is compiled in Apache by default.It enables you tocreate custom environment variables using information from an HTTP request.Youcan use such information in rewriting URLs or redirecting users to different pages.BrowserMatchThe BrowserMatchdirective sets and unsets custom environment variables whenthe regular expression matches a pattern found in the User-Agentheader of aHTTP request.The User-Agent header is sent by Web clients such as Webbrowsers, Web robots, and the like.Syntax: BrowserMatch regex variable[=value] [.]Context: Server configc4821-2 ch05.F 2/22/02 10:12 AM Page 108Part I &' Getting Started108For example, the following sets a variable called vbscriptto the value noif theUser-Agentheader field of the HTTP request contains the word Mozilla, and anenvironment variable called javascriptis set to 1because no value was specifiedfor this variable:BrowserMatch ^Mozilla vbscript=no javascriptLet s look at another example:BrowserMatch IE vbscript !javascriptHere, the variable javascriptis removed and the vbscriptis set to 1if the wordIEis found in the User-AgentHTTP request header.The !character removes thevariable from the environment.NoteA regular expression match is case sensitive.BrowserMatchNoCaseThe BrowserMatchNoCasedirective is same as the BrowserMatchdirective, exceptthat it provides case-insensitive matching for regular expressions
[ Pobierz całość w formacie PDF ]