apache server global configuration details of full

  • 2020-05-09 19:38:46
  • OfStack

Server identity configuration for Apache server global configuration

Server identification related instructions:
ServerName
ServerAdmin
ServerSignature
ServerTokens
UseCanonicalName
UseCanonicalPhysicalPort

The ServerAdmin and ServerTokens directives control what information about the server will appear in the documents generated by the server (such as error messages). The ServerTokens directive sets the value of the server HTTP response header field.
The ServerName, UseCanonicalName, UseCanonicalPhysicalPort directives are used to determine how to build a self-referential URL. For example, if a client requests a directory but does not include the slash "/" at the end of the directory name, Apache will redirect the client to the full name containing "/" so that the client can correctly parse the relative reference in the document.

ServerName instruction
Syntax: ServerName [scheme://] FQDN [:port]
This directive is used to set the server to identify its own host name and port number. Primarily used to create redirected URL.

For example, your web server's host name is example.bob.com, but your web server also has an DNS alias, www.bob.com, in the DNS server. If you want the web server to be more significant 1 point, you can use the ServerName directive in http.conf:
ServerName www.bob.com:80

When ServerName is not specified, the server attempts a reverse query of the IP address to infer the host name. If no port number is specified in ServerName, the server listens on all ports. To enhance reliability and predictability, you should specify a hostname and port number as shown in ServerName.
If you are using a virtual host based on the domain name, in < VirtualHost > The ServerName in the section will be to match the virtual host, and the hostname must be written in the "Host:" header.

ServerAdmin instruction
Syntax: ServerAdmin email-address |URL
This directive is used to set the administrator email address contained in the error message returned by the server to the client. It is convenient for users to get in touch with administrators in time after receiving error messages.

ServerAdmin bob@126.com

ServerSignature instruction
Syntax: ServerSignature. | Off | Email
Default: ServerSignature Off
This directive is used to configure the footer for server-side document generation (error message, mod_proxy's FTP directory list, mod_info's output). Using this directive to enable the footer is largely because when you are in a chain of one proxy servers, the user is largely unable to identify which server in the chain actually produced the error message that was returned.

http.conf this directive defaults to Off, so there are no error lines; Using On simply adds a line about the server version and ServerName being served;
For example, when I use ServerSignature, the following information appears when the web page is not opened:

Apache/2.2.11 (Unix)   PHP/5.2.8 Server at 192.168.120.240 Port 80

For versions after 2.0.44, the detailed server version number displayed will be controlled by the ServerTokens directive.

ServerTokens instruction
Syntax: ServerTokens Major | Minor | Min[imal] | Prod[uctOnly] | OS | Full
Default: ServerTokens Full
This directive controls whether the "Server:" response header from the server to the client contains information about the type of server operating system and the module description compiled into it.

Note: the ServerSignature directive must be enabled when using the ServerTokens directive.

ServerTokens Prod[uctOnly] : the server will send (for example) Apache  
Apache Server at 192.168.120.240 Port 80  
ServerTokens Major: the server will send (for example) Apache/2  
Apache/2 Server at 192.168.120.240 Port 80  
ServerTokens Minor: the server will send (for example) Apache/2.2  
Apache/2.2 Server at 192.168.120.240 Port 80  
ServerTokens Min[imal] : the server will send (for example) Apache/2.2.11
Apache/2.2.11 Server at 192.168.120.240 Port 80  
ServerTokens OS: the server will send (for example) : Apache/2.2.11 (Unix)
Apache/2.2.11 (Unix) Server at 192.168.120.240 Port 80
ServerTokens Full: the server will send (for example) Apache/2.2.11 (Unix) PHP/5.2.8
Apache/2.2.11 (Unix)   PHP/5.2.8 Server at 192.168.120.240 Port 80

UseCanonicalName instruction
Syntax: UseCanonicalName On | Off | DNS
Default: UseCanonicalName Off
This directive is used to construct the self-reference URL of Apache (1 URL back to the same server).

UseCanonicalName. : the domain name set by ServerName will be used for all self-referential URL, SERVER_NAME, SERVER_PORT in CGI. For example: if your web servers have their own domain name, and there is a corresponding in DNS NS records, and httpd. conf set ServerName domain, then you in the browser input http: / / 192.168.120.240 bbs, it will automatically this IP address into their corresponding domain name, such as http: / / www bob. com/bbs /. At this point, if other client computers are unable to properly parse the domain name of the web server, there will be a problem accessing the web server. Because the web server will automatically convert the IP address to the domain name.

UseCanonicalName Off: if the client provides the hostname and port, Apache will use this information provided by the client to build the self-referential URL. These values are the same as those used to implement domain-based virtual hosts and are available to the same clients. The CGI variables SERVER_NAME and SERVER_PORT are also built from the values provided by the client.

UseCanonicalName DNS: this setting is used to support browsers that do not provide an "Host:" header for a large number of IP-based web hosts. When you use this option, Apache reverse-parses the IP address of the server to which the client is connected, DNS, to build the self-referential URL.

UseCanonicalPhysicalPort instruction
Grammar: UseCanonicalPhysicalPort. | Off
Default: UseCanonicalPhysicalPort Off
This directive is used to configure how the server determines its own port.

UseCanonicalPhysicalPort. : it is possible for Apache to use the actual physical port number to conform to the UseCanonicalName directive when constructing the server's specification port.  
UseCanonicalPhysicalPort Off: Apache does not use the actual physical port number, but relies on all the configured information to construct a valid port number.

Note:
The order in which you decide to use the physical port number is as follows:
UseCanonicalName .
The port number specified by Servername
Physical port number
Default port number

UseCanonicalName Off | DNS
"Host:" port number provided by request header
Physical port number
The port number specified by Servername
Default port number
In the case of UseCanonicalPhysicalPort Off, the physical port number will be removed from the above order.

Apache server global configuration file location configuration section
 
File location related instructions:
CoreDumpDirectory
DocumentRoot
ErrorLog
LockFile
PidFile
ScoreBoardFile
ServerRoot

These instructions control the location of the various files required for Apache to function properly. If the pathname does not begin with the slash "/", then the file is considered a relative path to ServerRoot.

CoreDumpDirectory instruction
Syntax: CoreDumpDirectory directory-path
This directive controls the kernel dump directory used by Apache, which is located by default under "ServerRoot". Because this directory is usually unwritable to the user running the server, kernel dump 1 will not normally write. If you need a kernel dump during debugging, you can use this directive to specify another directory.

DocumentRoot instruction
Syntax: DocumentRoot directory-path
This directive is used to set the directory where httpd provides services. In the absence of instructions such as Alias, the server appends URL from the request to DocumentRoot to form a path to the document.
Such as:
DocumentRoot "/ usr local/httpd/htdocs"
So during a visit to http: / / 192.168.120.240 bbs/index html, is actually access/usr loca/httpd htdocs/bbs/index html.
If directory-path is not an absolute path, it is assumed to be a path relative to ServerRoot.
Such as:
ServerRoot "/ usr local httpd/"
DocumentRoot "htdocs"
So during a visit to http: / / 192.168.120.240 bbs/index html, actually will be positioned to/usr loca/httpd htdocs/bbs/index html.

ErrorLog instruction
Grammar: ErrorLog file-path | syslog[:facility]
Default: ErrorLog "logs/error_log"
This directive is used to set the file to log an error when the server encounters an error. If file-path is not an absolute path beginning with /, then it will be considered a relative path to ServerRoot.

LockFile instruction
Syntax: LockFile filename
This directive sets the location of the lock file used by Apache when the value of the AcceptMutex directive is fcntl or flock. 1. Keep the default values. The main reason for changing the default is that the logs directory is located on an NFS file system, because the lock file must be on a local disk. The PID of the primary server process is automatically added to the end of the file name.
Note: do not place the lock file in a directory where anyone has write permission, because someone can prevent the server from starting by creating a file with the same name as the lock file the server is trying to create.

PidFile instruction
Syntax: PidFile filename
Default: PidFile "logs/ httpd. pid"
This directive is used to set the server to record the files of the parent (monitoring process) PID.
If the specified path is not absolute, it will be considered a relative path to ServerRoot.

ScoreBoardFile instruction
Syntax: ScoreBoardFile file-path
This directive is used to set the file that stores the child process coordination data. Apache USES the scoreboard (scoreboard) to communicate between parent and child processes. Some systems require a document to facilitate communication. If this file is not specified, Apache will first attempt to build a complete scoreboard in anonymous Shared memory. If you fail, you will continue to try to create the file on disk using the file-based Shared storage. If you use this directive to specify the location of the file, Apache will always create the file on disk.
Placing ScoreBoardFile in RAM DISK helps greatly with access speed. But be careful where you put it and what permissions you have.

ServerRoot instruction
Grammar: ServerRoot directory-path
This directive is used to set the directory where the Apache server resides. 1 normally contains subdirectories conf/, logs/, etc. The relative path 1 of the other configuration files is generally based on this directory.
Such as:
ServerRoot "/ usr local httpd/"

Resource limit configuration for Apache server global configuration

Resource restriction related directives:
LimitRequestBody
LimitRequestFields
LimitRequestFieldsize
LimitRequestLine
RLimitCPU
RLimitMEM
RLimitNPROC
ThreadStackSize

The LimitRequest* series directives are used to limit the number of resources that Apache can use to read client requests. By limiting these values, you can mitigate some denial of service (DOS) attacks.  
The RLimit* series of instructions are used to limit the number of resources used by processes derived from the Apache child processes. Typically, these instructions control the resources used by the CGI script and the SSI exec command.  
The ThreadStackSize directive is used on some platforms to control stack size.

LimitRequestBody instruction

Grammar: LimitRequestBody bytes
Default: LimitRequestBody 0
This directive sets the maximum number of bytes the client can send an HTTP request. The LimitRequestBody directive can be applied to an entire server, a specific directory, a specific file, and a specific location. If the client's request exceeds the value set by LimitRequestBody, the server responds with an error message to the client and does not process the request.
Bytes is between 0 (unrestricted) and 2147483647 (2GB).
For example, if you allow a client to upload a file to a location and want to limit the size of the uploaded file to 500K,
LimitRequestBody 512000

LimitRequestFields instruction

Grammar: LimitRequestFields number
Default: LimitRequestFields 100
This directive is used to set the number of HTTP request header fields in a client request to the server. The number of header fields requested by a single client is rarely greater than 20, but this number can vary greatly depending on the client. This often depends on users configuring their browser extensions to support more detailed content negotiation. The optional HTTP extension is often implemented using the request header domain.
number is an integer between 0 (unrestricted) and 32767. The default value is the compile-time constant DEFAULT_LIMIT_REQUEST_FIELDS (published value 100).

LimitRequestFieldsize instruction

Syntax: LimitRequestFieldsize bytes
Default: LimitRequestFieldsize 8190
This directive sets the maximum number of bytes of the HTTP request header sent by the client. In general, the server needs this value to be large enough to accommodate the header field size of any request from a normal client. The size of the header field 1 is closely related to the content protocol supported by the browser.
In general, do not change this value, just use the default.

LimitRequestLine instruction

Syntax: LimitRequestLine bytes
Default: LimitRequestLine 8190
This directive is used to set the maximum number of bytes in the HTTP request line sent by the client. The request line includes the HTTP method, URL, protocol version, and so on. So the LimitRequestLine directive can limit the length of URL, and the server will need this value to be large enough to load all of its resource names, including all of the information that might be passed in the query portion of the GET request.
In general, do not change this value, just use the default.

RLimitCPU instruction

Grammar: RLimitCPU seconds | max [seconds|max]
Default: undefined, using operating system defaults
This directive is used to set the maximum number of seconds that a process derived from the Apache child process can occupy in CPU.
You can set one or two parameters here. The first parameter sets soft resource limits for all processes, and the second parameter sets maximum resource limits. Both parameters can be set to 1 value or "max" (meaning set to the maximum allowed by the operating system). Increasing the maximum value of this resource limit requires running the server with root or setting it in the initialization startup statement.
This directive only applies to processes derived from the Apache child process, not the Apache child process itself. This scope includes the CGI script and the SSI execution command, excluding all processes derived from the Apache parent. For example, pipe logs.
The CPU resource limit represents the number of seconds taken per process.

RLimitMEM instruction

Grammar: RLimitMEM bytes | max [bytes|max]
Default: undefined, using operating system defaults
This directive is used to set the maximum number of bytes consumed by a process derived from the Apache child process.
You can set one or two parameters here. The first parameter sets soft resource limits for all processes, and the second parameter sets maximum resource limits. Both parameters can be set to 1 value or "max" (meaning set to the maximum allowed by the operating system). Increasing the maximum value of this resource limit requires either running the server with root or setting it in the initialization startup statement.
This directive only applies to processes derived from the Apache child process, not the Apache child process itself. This scope includes the CGI script and the SSI execution command, excluding all processes derived from the Apache parent. For example, pipe logs.
The memory resource limit is expressed as the number of bytes consumed per process.

RLimitNPROC instruction

Syntax: RLimitNPROC number | max [number|max]
Default: undefined, using operating system defaults
This directive is used to set the number of processes derived from Apache child processes.
You can set one or two parameters here. The first parameter sets soft resource limits for all processes, and the second parameter sets maximum resource limits. Both parameters can be set to 1 value or "max" (meaning set to the maximum allowed by the operating system). Increasing this maximum resource limit requires running the server with root or setting it in an initialization startup statement.
This directive only applies to processes derived from the Apache child process, not the Apache child process itself. This scope includes the CGI script and the SSI execution command, excluding all processes derived from the Apache parent. For example, pipe logs.
The process limit controls the number of processes per user.

ThreadStackSize instruction

Syntax: ThreadStackSize size
Default: 65536 on NetWare, operating system default on other platforms
This directive is used to set the maximum stack size (bytes) allowed by the thread handling the client connection (including calling the module to assist in processing).
In most cases, the operating system's default stack size is reasonable. But in some cases, this value needs to be adjusted:
On a platform with a smaller default stack size (such as HP-UX), Apache may crash when using a third module that requires a larger stack size. Such a problem can be solved by setting ThreadStackSize to a larger value. This adjustment should only be required if the third party module provider explicitly requests it, or if you diagnose it as a crash due to the small stack space.
On some platforms, if the default stack space is larger than the server needs to run, reducing ThreadStackSize to less than the operating system default can increase the maximum number of threads allowed to be generated per process. This type of tuning should only be used in the test environment, and all server processes should be fully tested, since processing some rare requests requires a large stack space. A small change in server configuration could make the current ThreadStackSize Settings inappropriate.


Related articles: