Apache Server Global Configuration detailed

Source: Internet
Author: User

Server Identity Related directives:
ServerName
ServerAdmin
Serversignature
Servertokens
Usecanonicalname
Usecanonicalphysicalport

The serveradmin and Servertokens directives control what information about the server will appear in the server-generated document (such as error messages). The Servertokens directive sets the value of the server HTTP response header field.
The ServerName, Usecanonicalname, and usecanonicalphysicalport directives are used to determine how to construct a self-referencing URL, for example, a client makes a request to a directory, but does not contain the last slash "/" of the directory name, Apache redirects the client to the full name of the containing "/" so that the client can correctly parse the relative reference in the document.

servername Directive
Syntax: ServerName [scheme://] FQDN [:p ORT]
This instruction is used to set the host name and port number that the server uses to identify itself. Used primarily to create a redirect URL.

For example, your Web server's host name is example.bob.com, but your Web server has a DNS alias www.bob.com in the DNS server at the same time. And you want the Web server to be a little more significant, you can use the servername directive in http.conf to implement:
ServerName www.bob.com:80

When servername is not specified, the server attempts to reverse-query 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 use the specified host name and port number shown in ServerName.
If you are using a domain-based virtual host, the ServerName in the <VirtualHost> segment will be to match this virtual host, and the hostname must be written in the "host:" Request header.

serveradmin Directive
Syntax: ServerAdmin email-address| Url
This instruction is used to set the administrator email address contained in the error message returned to the client by the server. It makes it easy for users to get in touch with the administrator when they receive the error message.

ServerAdmin [email protected]

serversignature directive
Syntax: Serversignature. | Off | Email
Default: Serversignature Off
This instruction is used to configure the footer of the server-side generated document (Error message, mod_proxy FTP directory list, mod_info output). Using this directive to enable this footer is mainly in the chain of a proxy server, the user basically cannot identify exactly which server in the chain actually produces the error message returned.

http.conf the directive is off by default, so there is no error line; Using on will simply add a line about the server version and the servername that is serving the service;
For example, when I use Serversignature., the following information appears when you do not have a Web page open:

apache/2.2.11 (Unix) php/5.2.8 Server at 192.168.120.240 Port 80

For later versions of 2.0.44, a detailed server version number is displayed and will be controlled by the Servertokens directive.

servertokens Directive
Syntax: Servertokens Major | Minor | Min[imal] | Prod[uctonly] | OS | Full
Default: Servertokens full
This instruction is used to control whether the "server:" Answer header that the server responds to the client contains information about the type of server operating system and the module description of the compiled input.

Note: The serversignature directive must be enabled when using the Servertokens directive.

Servertokens Prod[uctonly]: 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: 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 Directive
Syntax: Usecanonicalname on | Off | Dns
Default: Usecanonicalname Off
This instruction is used to construct the Apache self-referencing URL (a URL that refers back to the same server).

Usecanonicalname.: The domain name set by servername is used for all self-referencing URLs, server_name, server_port in CGI. For example: If your Web server has its own domain name, and there is a corresponding NS record in DNS, and httpd.conf will servername set the domain name, then you enter Http://192.168.120.240/bbs in the browser, It will automatically turn this IP address into its corresponding domain name, such as http://www.bob.com/bbs/. At this point, if the other client's computer does not correctly parse the Web server's domain name, there will be a problem accessing the Web server. Because the Web server automatically transforms the IP address into a domain name.

Usecanonicalname OFF: If the client provides a host name and port, Apache will use this information provided by the client to build the self-referencing URL. These values are the same as the values used to implement the domain-based virtual host and are available to the same client. CGI variables server_name and server_port are also built by the values provided by the client.

Usecanonicalname DNS: This setting is used to support browsers that do not provide a "Host:" header for a large number of IP-based virtual hosts. With this option, Apache parses the IP address of the server that the client is connected to to build the self-referencing URL.

usecanonicalphysicalport Directive
Syntax: Usecanonicalphysicalport. | Off
Default: Usecanonicalphysicalport Off
This instruction is used to configure how the server determines its own port.

Usecanonicalphysicalport.: Apache is likely to use the actual physical port number in order to conform to the Usecanonicalname directive when constructing the canonical port of the server.
Usecanonicalphysicalport Off:apache does not use the actual physical port number, but relies on all configured information to construct a legitimate port number.

Attention:
The order in which you decide to use the physical port numbers is as follows:
Usecanonicalname.
ServerName The specified port number
Physical port number
Default port number

Usecanonicalname Off | DNS
"Host:" The port number provided by the request header
Physical port number
ServerName The specified port number
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 Chapter

File location Related directives:
Coredumpdirectory
DocumentRoot
Errorlog
LockFile
Pidfile
Scoreboardfile
ServerRoot

These directives control the positioning of the various files required for Apache to work properly. If the pathname does not begin with a slash "/", then the file is assumed to be relative to the ServerRoot path.

coredumpdirectory directive
Syntax: Coredumpdirectory directory-path
This command is used to control the kernel dump directory used by Apache, which is located by default under "ServerRoot". Because this directory is generally not writable for the user running the server, kernel dumps generally do not write content. If you need a kernel dump in debugging, you can use this command to specify a different directory.

documentroot Directive
Syntax: DocumentRoot directory-path
This command is used to set the directory where the HTTPD service is provided. In the absence of an instruction like alias, the server appends the URL in the request to DocumentRoot to form the path to the document.
For example:
DocumentRoot "/usr/local/httpd/htdocs"
So when you access http://192.168.120.240/bbs/index.html, you are actually visiting/usr/loca/httpd/htdocs/bbs/index.html.
If the directory-path is not an absolute path, it is assumed to be relative to the ServerRoot path.
For example:
ServerRoot "/usr/local/httpd/"
DocumentRoot "Htdocs"
When you access http://192.168.120.240/bbs/index.html, you will actually be positioned to/usr/loca/httpd/htdocs/bbs/index.html.

errorlog Directive
Syntax: errorlog file-path | Syslog[:facility]
Default: Errorlog "Logs/error_log"
This command is used to set the file that logs the error log when the server encounters an error. If File-path is not an absolute path with/begins, it will be considered a relative path relative to ServerRoot.

lockfile Directive
Syntax: LockFile filename
This instruction sets the location of the lock file used by Apache when the value of the Acceptmutex instruction is fcntl or flock. The default value is generally maintained. The primary reason for changing the default value is that the logs directory resides on an NFS file system because the lock file must reside on the local disk. The PID of the master server process is automatically appended to the file name.
Note: Do not place the lock file in a directory where anyone has write permissions, because someone else can prevent the server from starting by creating a file with the same name as the lock file that the server attempts to establish.

pidfile Directive
Syntax: pidfile filename
Default: Pidfile "Logs/httpd.pid"
This instruction is used to set the server to record the parent process (monitoring process) PID file.
If the specified is not an absolute path, it is considered to be a relative path relative to ServerRoot.

scoreboardfile Directive
Syntax: Scoreboardfile file-path
This directive is used to set up files that store child process coordination data. Apache uses the scoreboard (scoreboard) to communicate between the parent and child processes. Some organizations require a file to help communicate. If this file is not specified, Apache will first attempt to establish a complete scoreboard in anonymous shared memory. If it fails, it will continue to attempt to build this file on disk using file-based shared storage. If you use this directive to specify the location of this file, Apache will always create this file on disk.
Placing Scoreboardfile in RAM disk is a great help in accessing speed. However, be aware of the placement and permissions.

serverroot directive
Syntax: ServerRoot directory-path
This command is used to set the directory where the Apache server resides. Generally include conf/, logs/and other subdirectories. The relative paths of other profiles are generally based on this directory.
For example:
ServerRoot "/usr/local/httpd/"

Apache Server Global Configuration Resource limit configuration Chapter

Resource Restriction related directives:
Limitrequestbody
Limitrequestfields
Limitrequestfieldsize
Limitrequestline
Rlimitcpu
Rlimitmem
Rlimitnproc
Threadstacksize

The limitrequest* series directives are used to limit the amount of resources that Apache uses in the process of reading client requests. By limiting these values, some denial of service (DOS) attacks can be mitigated.
The rlimit* series directives are used to limit the amount of resources used by processes that are derived by Apache child processes. Typically, these directives are used to control the resources used by CGI scripts and SSI exec commands.
The threadstacksize directive is used on some platforms to control the stack size.

limitrequestbody directive

Syntax: limitrequestbody bytes
Default value: Limitrequestbody 0
This instruction is used to set the maximum number of bytes of HTTP requests sent by the client. The limitrequestbody directive can act on the entire server, specific directories, specific files, and specific locations. If the client's request exceeds the value set by the Limitrequestbody, the server responds with an error message to the client and does not process the request.
The bytes is between 0 (unrestricted) and 2147483647 (2GB).
For example: you allow the client to upload the file to a location, and you want to limit the size of the uploaded file to 500K.
Limitrequestbody 512000

limitrequestfields directive

Syntax: Limitrequestfields number
Default: Limitrequestfields 100
This instruction is used to set the number of HTTP request header fields that the client requests to the server. In general, the number of client request header fields is rarely greater than 20, but the number of client-side differences will vary greatly. This often depends on the user configuring their browser extensions to support more detailed content negotiation. Optional HTTP extensions are often implemented using the request header domain.
Number is an integer that is 0 (unrestricted) to 32767. The default value is the compile-time constant Default_limit_request_fields (the publication value is 100).

limitrequestfieldsize directive

Syntax: limitrequestfieldsize bytes
Default: Limitrequestfieldsize 8190
This instruction is used to set the maximum number of bytes of HTTP request headers sent by the client. In general, the server needs this value to be large enough to accommodate the size of the header domain of any request from a normal customer. The size of the header field is generally closely related to the content protocol supported by the browser.
In general, do not change this value, use the default.

limitrequestline directive

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

rlimitcpu directive

Syntax: rlimitcpu seconds | Max [Seconds|max]
Default: Undefined, using the operating system default value
This instruction is used to set the maximum number of seconds that the Apache child process-derived process consumes the CPU.
You can set one or two parameters here. The first parameter sets the soft resource limit for all processes, and the second parameter sets a maximum resource limit. Two parameters can be set to a numeric value or "Max" (indicating the maximum allowed by the operating system). To increase the maximum value for this resource limit, you need to run the server as root or set it in the Initialize startup statement.
This directive only works on processes that are derived from the Apache subprocess, not the Apache child process itself. This scope includes CGI scripts and SSI execution commands, excluding all processes derived from the Apache parent process. such as pipeline logs.
CPU resource limits indicate the number of seconds per process consumed.

rlimitmem directive

Syntax: Rlimitmem bytes | Max [Bytes|max]
Default: Undefined, using the operating system default value
This instruction is used to set the maximum number of bytes of memory that the process derived by the Apache child process consumes.
You can set one or two parameters here. The first parameter sets the soft resource limit for all processes, and the second parameter sets a maximum resource limit. Two parameters can be set to a numeric value or "Max" (indicating the maximum allowed by the operating system). To increase the maximum value for this resource limit, you need to run the server as root or set it in the Initialize startup statement.
This directive only works on processes that are derived from the Apache subprocess, not the Apache child process itself. This scope includes CGI scripts and SSI execution commands, excluding all processes derived from the Apache parent process. such as pipeline logs.
Memory resource limits are expressed as the number of bytes consumed per process.

rlimitnproc directive

Syntax: Rlimitnproc number | Max [Number|max]
Default: Undefined, using the operating system default value
This instruction is used to set the number of processes that the Apache child process derives.
You can set one or two parameters here. The first parameter sets the soft resource limit for all processes, and the second parameter sets a maximum resource limit. Two parameters can be set to a numeric value or "Max" (indicating the maximum allowed by the operating system). To increase the maximum value for this resource limit, you need to run the server as root or set it in the Initialize startup statement.
This directive only works on processes that are derived from the Apache subprocess, not the Apache child process itself. This scope includes CGI scripts and SSI execution commands, excluding all processes derived from the Apache parent process. such as pipeline logs.
Process throttling controls the number of processes per user.

threadstacksize directive

Syntax: Threadstacksize size
Default: 65536 on NetWare, equals OS default on other platforms
This instruction is used to set the maximum stack size (in bytes) allowed for threads that handle client connections (including calling modules to assist processing).
In most cases, the default stack size for the operating system is reasonable. However, 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 some third-party modules that require a larger stack size. Such a problem can be resolved by setting the threadstacksize to a larger value. This adjustment should only be required if the third-party module provider explicitly requires it, or if you determine by diagnostics that the stack space is too small to cause a crash.
On some platforms, if the default stack space is greater than the space required for the server to run, then lowering the threadstacksize value to less than the operating system default allows for an increase in the maximum number of threads allowed to be generated per process. This type of adjustment should be used only in a test environment and fully tested for all server processes, because there is a large stack space required to handle some rare requests. A small server configuration change could make the current threadstacksize settings inappropriate.

Apache Server Global Configuration detailed

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.