Apachehttpd. conf settings

Source: Internet
Author: User
Tags apache error log
The configuration of Apachehttpd. conf-Linux Enterprise Application-Linux server application information. For details, refer to the following section. This file stores some of the most important configuration information of Apache. It is also the first place in adjustment performance. I will introduce the main configuration options,
Servertype

This option determines how Apache is executed. Apache can run as an independent application or be called by inetd when an HTTP request arrives through an appropriate port (usually port 80. When inetd runs, it consumes much less resources, because Apache needs to be started for each request, which reduces the overall performance of the web server. It is better to set the independent working mode.

Port

This parameter is only used for servers that work in standalone mode. Usually port 80.

HostnameLookups

This setting determines whether the web server resolves the host name for each accessed IP address. If it is set to on, the access log will store the host name instead of the IP address. The disadvantage is that it affects the speed. When this function is enabled, the name of each request is queried. If the number of requests for a service is large, the server performance will be seriously reduced. By default, Apache sets this parameter to off and provides a logresolve tool to resolve the host name.

User

Server process user, usually set to "nobody ".

Group

The Group Name of the running server, usually set to "nobody ".

ServerAdmin

The email address of the server administrator. This will appear on the error page.

ServerRoot

Specifies the storage location of the configuration file and server diary file. Unless you need to change the settings for special reasons, it is generally the same as the directory where Apache is located.

ErrorLog

This parameter indicates the storage location of the Apache error log file. You can set the record content. Generally, the following important information is recorded: start time, stop time, and any errors (such as 404 errors) encountered by the user ).

LogLevel

Determines the time to fill your diary file. The option "Warn" is sufficient in most cases unless you plan to carefully diagnose the problem.

LogFormat

This function specifies the format of the log file on the server. You can create a specific format that contains additional information (such as referrers. The following is an example of a common combination format.

LogFormat "% h % l % u % t" % r "%> s % B" % {Referer} I "" % {User-Agent} I "combined

CustomLog

This command is used in the same way as LogFormat alias.

Timeout

The time allowed for establishing a connection, in seconds.

KeepAlive

Enable this option for persistent connections. This indicates that a single connection can be used for more than one request. This is of course a good thing, because it reduces the overall time required to establish a connection, especially in a single web document, which may require five or six requests (e.g ).

MaxKeepAliveRequests

The maximum number of requests for each persistent connection. This number should be set to a higher (at least 100 ).

KeepAliveTimeout

This option is used to tell the server the waiting time when the next request arrives. The default value is 15 seconds. You can extend or shorten the waiting time based on the connection conditions of the same customer. When the connection with the customer is slow, more wait time is required. Remember, if this value is too high, it may lead to server processes being empty and connections that will never arrive.

MinSpareServers

The minimum number of server processes waiting for requests to appear at any time. Changing this parameter may improve the server performance when loading the process. The default value is 5.

MaxSpareServers

This value tells Apache that there are too many redundant processes. By ensuring that there are no excessive processes, this will help protect system resources.

StartServers

The number of processes on the server at initial startup. It is usually the same as the setting value of MinSpareServers.

MaxClients

Maximum number of customers that can be connected at any time. Because the customers of the Apache server are related to the number of processes, in extreme cases, resource usage may be very concentrated. At this time, this setting value will protect your server from crash. But do not set this value too low, because once this is done, users may not be connected during peak hours.

MaxRequestsPerChild

The maximum number of requests that a single process can process. To avoid memory overflow, the request that exceeds the specified value is forcibly terminated. The default value is 30.

Listen

Bind Apache to the specified port or address. You can specify multiple listener options. In this case, a single server can be used as several different websites.

And

This option allows Apache to provide multiple address services, such as multiple domain names. This item is used with Listen. At the same time, any httpd. conf option can also be placed in a VirtualHost command. This means that you can specify different ServerAdmins and logfiles for each virtual server. The following is an example:

ServerAdmin brian@mysite.com

DocumentRoot/usr/docs/mysite

ServerName www.mysite.com

ErrorLog/var/log/web/mysite. log

TransferLog/var/log/webmysite-access.log

Access. conf contains most settings related to the same security and user access in Apache. In this file, directory indexes and SSI include commands can be configured one by one according to directories. The following are important configuration options:

And (Also and)

This is the main option in the access. conf file. When constructing the access. conf file, when starting the file, set the parameter to the strictest restrictive value, and then gradually relax the restrictions on different documents on the server.

Options

With this parameter, you can enable or disable a function for each directory control. Generally, it is not set to "All". You can specify the number of options at will, because des and ExecCGI may sometimes pose security risks. Except for the # include exec statement that does not allow the execution of CGI programs, IncludesNOEXEC serves the same purpose as des (the <-- # include --> statement can be used in this document ).

AllowOverride

This option defines the level of control that can be obtained by using the. htaccess file. These files can be placed in the content directory to replace the default settings in the specified directory (in the access. conf file ). In some cases, this is very convenient, because you do not need to access the root directory when you reconfigure the specified directory, but using such a file will slightly affect the performance, this is because the web server must read this file when accessing the options that determine the directory function. Access. conf can control which parameter to use in these files. In addition, the. htaccess file is used in the same way as the initial ccess. conf file.

Order

It is used together with Allow From and Deny From (described below. Specifies the order of access verification. For example, it can specify allow before deny, and then allow access in addition to the value where it should be disabled. If deny is specified first, access to this directory is denied by default.

Allow From and Deny From

Determine who should access the directory specified by the command. The usage of None and All is straightforward. You can also allow or deny access based on the user's domain name (simply specify the domain name as the parameter ).

To better illustrate these options and how they are used in the access. conf file, the following is a simple example:

Options FollowSymLinks

AllowOverride None

Options IncludesNOEXEC FollowSymlinks

AllowOverride None

Order allow, deny

Allow From All

AllowOverride None

The deny from allsrm. conf file determines how the server processes more requests, such as the index format and content type definition.

DocumentRoot ""

The root directory that stores all online content.

UserDir

The home directory where users store their HTML documents. If ~ Username parameter. The server searches for this directory in the home directory of the user.

DirectoryIndex

When no file is specified in the URL, the default file name in the requested directory is used. Usually index.html.

FancyIndexing

Determines the display style of the Directory Index (when DirectoryIndex does not exist ). If you have disabled the index, this parameter does not work.

HeaderName

Specify the header file name at the top of the index in the directory, if found.

ReadmeName

The name of the readme file. If it is found, it is marked as an index.

AccessFileName

The name of the access control file to be searched in each directory. The default name is. htaccess.

ScriptAlias ""

The alias of a specific directory used in the Script URL.

ScriptAlias/cgi-bin/"/usr/local/mysite/scripts /"

AddType

This parameter allows you to configure a certain type of file that the web server can recognize with a file extension, for example:

AddType application/x-httpd-php. php

AddHandler

The file extension allows you to associate a file with a specific "handlers" or server-side to help the application. For example, by using AddHandler, you can use CGI scripts and dynamically generated HTML on the server. See the following example:

AddHandler cgi-script. cgi

AddHandler server-parsed. shtml
Related Article

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.