Apacheserver Global Configuration Specific explanation

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 be in today's server-generated documents, such as error messages. The servertokens instruction sets the value of the Serverhttp response header field.
The ServerName, Usecanonicalname, and usecanonicalphysicalport directives are used to determine how to construct self-referencing URLs, for example. A client makes a request to a folder, but does not include the last Slash "/" of the folder name, and Apache redirects the client to the full name including "/". So that the client can parse the relative references in the document correctly.



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

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

When servername is not specified, the server attempts to reverse-query the IP address to determine the host name. Assuming the port number is not specified in the servername, the server listens for all ports. To enhance reliability and scalability, you should use the specified host name and port number as shown in servername.


Assuming that a domain-based virtual host is used, 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 included 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 directive is used to configure the server-side generated document footer (Error message, mod_proxy FTP Folder List, Mod_info output). Using this directive to enable this footer is primarily in the chain of a proxy server, where the user basically cannot identify which server in the chain actually generated the error message that was returned. The directive is off by default in

http.conf, so there is no error line; Using on will simply add a row about the server version number and the ServerName that is serving the service.
For example. After I use Serversignature., the following information appears when the Web page is not open:

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

For the 2.0.44 version number, the display of the specific server version number 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 includes information about the type of server operating system and the description of the compiled module.

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:server will send (for example): apache/2 
Apache/2 Server at 192.168.120.240 Port 80 
Servertokens Minor:server will send (for example): apache/2.2 
apache/2.2 Server at 192.168.120.240 Port 80 
Servertokens Min[imal]:server Send (for example): apache/2.2.11
apache/2.2.11 Server at 192.168.120.240 Port 80 
Servertokens Os:server Send (for example): apache/2.2.11 (Unix)
apache/2.2.11 (Unix) Server at 192.168.120.240 Port
Servertokens Full:server 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

usecanonicalname directive
Syntax: Usecanonicalname on | Off | DNS
Default: Usecanonicalname Off
This directive constructs a self-referencing URL for Apache (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: Suppose your webserver has its own domain name and has 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 take the initiative to turn this IP address into its corresponding domain name. For example http://www.bob.com/bbs/.

At this point, assuming that the other client computer does not correctly parse the webserver domain name, then visit this webserver will be a failure. Since webserver will take the initiative to convert the IP address into a domain name.



Usecanonicalname OFF: Suppose the client provides the hostname and Port,apache will use this information provided by the client to build the self-referencing URL. These values are the same as those used to implement domain-based virtual hosts, and are available for 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 in DNS reverse. To build a 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 server's canonical port.


Usecanonicalphysicalport Off:apache does not use the actual physical port number. Instead, it relies on all of the configured information to construct a valid port number.

Attention:
Determine the order in which the physical port number is used such as the following:
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.

apacheserver 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. Assuming that the path name does not start with a slash "/", it is assumed that the file is relative to the ServerRoot path.

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

documentroot Directive
Syntax: DocumentRoot directory-path
This instruction is used to set the folder where the HTTPD service is provided.

Without using an instruction like alias. The server appends the URL in the request to DocumentRoot to form the path to the document.
Like what:
DocumentRoot "/usr/local/httpd/htdocs"
So when you visit http://192.168.120.240/bbs/index.html, you're actually visiting/usr/loca/httpd/htdocs/bbs/index.html.
Suppose Directory-path is not an absolute path. It is assumed to be a path relative to ServerRoot.


Like what:
ServerRoot "/usr/local/httpd/"
DocumentRoot "Htdocs"
So when you visit 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 instruction is used to set the file that logs the error log when the server encounters an error. Assuming that 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 main reason for changing the default value is that the logs folder is located on an NFS file system. The lock file must be located on the local disk. The PID of the primary server process is itself actively added to the file name.
Note: Do not place the lock file in a folder that has write permissions for everyone. Because someone else can prevent the server from starting by creating a file with the same name as the lock file that the server is trying 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 (monitor process) PID file.


Assuming that the specified is not an absolute path, it will be assumed 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.

Assume that this file is not specified. Apache will first attempt to establish a complete scoreboard in anonymous shared memory. Assumptions fail. 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 how fast you get access.

However, be aware of the placement and permissions.

ServerRoot directive
Syntax: ServerRoot directory-path
This command is used to set the folder where the Apacheserver is located.

Generally include conf/, logs/and other sub-folders.

The relative paths of other profiles are generally based on this folder.
Like what:
ServerRoot "/usr/local/httpd/"

Apacheserver 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.

Usually. 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 folders, specific files, and specific locations.

Assuming that the client's request exceeds the value set by the Limitrequestbody, the server responds with an error message to the client. Instead of handling the request.


The bytes is between 0 (unrestricted) and 2147483647 (2GB).
For example: You agree that the client will upload the file to a location, and you want to limit the upload file size 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 in the client to the server request. Typically, the number of client request header fields is less than 20. But the number of client differences will also be very big difference.

This often depends on the user configuring their browser extensions to support more specific 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 advertised 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. Generally speaking. Server needs this value to be large enough. To accommodate the size of the header domain of the ordinary customer regardless of the request. The size of the header field is generally closely related to the content protocol supported by the browser.
Under normal circumstances, do not change this value, using the default is possible.

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 contains the HTTP method, URL, protocol version number, and so on.

Therefore, the Limitrequestline directive can limit the length of the URL, which the server needs 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.
Under normal circumstances, do not change this value. You can use it by default.



RLIMITCPU directive

Syntax: rlimitcpu seconds | Max [Seconds|max]
Default: no definition, use 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.
It is possible to set one or two of the parameters here.

The first parameter sets the soft resource limit for all processes, and the second parameter sets the maximum resource limit. Two parameters can be set to a numeric value or "Max" (the maximum value that is set to the operating system's consent). To increase this resource limit, the maximum value needs to be performed either as root server or in the initialization startup statement.
This directive only works on processes derived from the Apache subprocess, not the Apache child process itself.

This scope contains CGI scripts and SSI run commands, and does not contain all the processes derived from the Apache parent process. For example, pipeline logs.
CPU resource limits indicate the number of seconds per process consumed.



RLIMITMEM directive

Syntax: Rlimitmem bytes | Max [Bytes|max]
Default: no definition, use 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.


It is possible to set one or two of the parameters here. The first parameter sets the soft resource limit for all processes, and the second parameter sets the maximum resource limit.

Two parameters can be set to a numeric value or "Max" (the maximum value that is set to the operating system's consent).

To increase this resource limit, the maximum value needs to be performed either as root server or in the initialization startup statement.


This directive only works on processes derived from the Apache subprocess, not the Apache child process itself.

This range contains CGI scripts and SSI run commands. Does not contain all processes derived from the Apache parent process. For example, pipeline logs.
Memory resource limits are expressed as the number of bytes consumed per process.



RLIMITNPROC directive

Syntax: Rlimitnproc number | Max [Number|max]
Default: no definition, use operating system default value
This instruction is used to set the number of processes that the Apache child process derives.


It is possible to set one or two of the parameters here.

The first parameter sets a soft resource limit for all processes. The second parameter sets a maximum resource limit.

Two parameters can be set to a numeric value or "Max" (the maximum value that is set to the operating system's consent). To increase this resource limit, the maximum value needs to be performed either as root server or in the initialization startup statement.
This instruction only works on processes that are derived from the Apache subprocess. Rather than the Apache child process itself. This scope contains CGI scripts and SSI run commands, and does not contain all the processes derived from the Apache parent process. For example, 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) that the thread that handles the client connection (which contains the calling module to assist processing) agrees to use.
Most of the cases. The operating system default stack size is very reasonable. But in some cases. This value needs to be adjusted:
On a platform with a smaller default stack size (for example, HP-UX). Apache may crash when using some third-party modules that require a larger stack size.

This problem can be resolved by setting the threadstacksize to a larger value. This adjustment should only be required if the third-party module provider understands the requirements, or if you determine by diagnostics that the stack space is too small to cause a crash.
On some platforms. Assuming that the default stack space is greater than the space required for server execution, reducing the threadstacksize value to less than the operating system default allows the maximum number of threads to be generated per process to be added.

This type of adjustment should only be used in a test environment. And make a full test of all the server processes. Due to the large stack space required to handle some rare requests. A very small server configuration change could make the current threadstacksize settings inappropriate.

Apacheserver Global Configuration Specific explanation

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.