Apache HTTP Latest official configuration (Chinese version)

Source: Internet
Author: User
Tags aliases format anonymous define file system variables version variable

  Article Introduction: The latest official Chinese version of Apache profile. Help the Web server administrator to configure Apache more conveniently.


# Based upon the NCSA server configuration files originally by Rob McCool.

#参照NCSA服务器的配置文件, the original was released by Rob McCool.


# This is the main Apache server configuration file. It contains the

# Configuration directives that give the server's its instructions.

# <URL:http://httpd.apache.org/docs-2.0/> For detailed information about

# the directives.

#这是Apache The primary configuration file for the server. It contains configuration directives to indicate that the server

#请参考 http://httpd.apache.org/docs-2.0 to learn more about instructions

# don't simply read the instructions in without understanding

# What they do.  They ' re here as hints or reminders. If you are unsure

# Consult the online docs. You have been warned.

#不要仅仅是阅读本指令, and should understand what the instructions do. Here is only a hint of the effect.

#如果你不清楚请参阅在线文档. Special Tips

# The configuration directives are grouped into three basic sections:


# 1. Directives that control the operation of the Apache server process as a

# Whole (the ' Global Environment ').

# 1. Directives that control the global operation of Apache Server (Global environment variable).

# 2. Directives that define the parameters of the ' main ' or ' default ' server,

# which responds to requests this aren ' t handled by a virtual host.

# These directives also provide default values for the settings

# all virtual hosts.

# 2. Configure the main service or the default service directive, which responds to requests outside of the virtual host.

# It also contains some default parameters for the virtual host

# 3. Settings for virtual hosts, which allow WEB requests to is sent to

# different IP addresses or hostnames and have them by the

# same Apache server process.

# 3. Virtual host settings, which allow requests to be sent to different IP or host names to be processed by the same Apache service # processor

# Configuration and LogFile names:if the filenames for specify

# of the server ' s control files begin with "/" (or "drive:/" for Win32), the

# Server would use that explicit path. If the filenames do *not* begin

# with '/', the value of ServerRoot is prepended--so ' logs/foo.log '

# with ServerRoot set to "C:/Program Files/apache group/apache2" 'll be interpreted by the

# server as "C:/Program Files/apache group/apache2/logs/foo.log".

#配置和日志文件名: If you specify a filename that starts with "/" (in Win32:/), the server will be treated as an absolute path. If it does not begin with "/", then it is not interpreted relative to serverroot, so for Logs/foo.log, when ServerRoot is "C:/Program files/apache group/apache2", it means

C:/Program Files/apache group/apache2/logs/foo.log File

# Note:where filenames are specified, you must use forward slashes

# instead of backslashes (e.g., "C:/apache" instead of "C:\apache").

Note that in the definition of the filename, you must use a forward slash, not a backslash, such as C:/apache instead of a c:\apache

# If a drive omitted, the drive on which Apache.exe is located

# 'll is used by default. It is recommended this you always supply

# an explicit drive-absolute paths, however, to avoid

# confusion.

#如果省略了盘符, the default value is the disk character where Apache.exe is located

It is recommended that you always use explicit disk characters in an absolute path to help eliminate misunderstandings

### Section 1:global Environment



# The directives in this section affect the overall operation of Apache,

# such as the number of concurrent requests it can handle or where it

# can find its configuration files.

#本部分的指令将影响整个Apache服务器, such as the number of concurrent requests it can handle or where it can find its configuration file


# serverroot:the top of the directory tree under which the server ' s

# Configuration, error, and log files are kept.

# ServerRoot: Server configuration, errors and root directory of log files

# note! If you are intend to, this is on a NFS (or otherwise network)

# mounted FileSystem then please read the Lockfile documentation (available

# at <URL:http://httpd.apache.org/docs-2.0/mod/mpm_common.html#lockfile>);

# You'll save yourself a lot of trouble.

#注意: If you save it on NFS or on a mounted file system on the network, you should then read the Lockfile document http://httpd.apache.org/docs-2.0/mod/mpm_common.html# Lockfile, will be able to solve a lot of your trouble.

# do does not add a slash at the end of the directory path.


ServerRoot "C:/Program Files/apache group/apache2"

ServerRoot: Root directory


# Scoreboardfile:file used to store internal server process information.

# If unspecified (the default), the scoreboard'll be stored in an

# Anonymous shared memory segment, and'll is unavailable to Third-party

# applications.

Scoreboardfile: Save processing information inside the server

If you are undecided (the default state), scoreboard will be saved in an anonymous shared memory segment and is not available to third parties

# If specified, ensure that no two invocations of Apache share the same

# Scoreboard file. The scoreboard file must is STORED on A local DISK.

#如果已定义, make sure that the two invocations of Apache cannot share the same scoreboard. Scoreboard files must be stored on a disk that can be allocated

#ScoreBoardFile Logs/apache_runtime_status


# pidfile:the file in which the server should a record its process

# identification number when it starts.

#PidFile: When the server is up, the server needs to store its process ID number in this file

Pidfile Logs/httpd.pid


# timeout:the number of seconds before receives and sends time out.

#Timeout: Timeout setting for receiving and sending data, number of seconds

Timeout 300


# Keepalive:whether or Allow persistent connections (more than

# One request per connection. Set to ' off ' to deactivate.

#KeepAlive: Whether to support persistent joins (instead of building one connection per request), turn off this feature

KeepAlive on


# maxkeepaliverequests:the Maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend you the leave this number is high and for maximum performance.

#MaxKeepAliveRequests: The maximum number of requests allowed during a persistent connection. Set to 0 means no limit

Recommended to a higher number to improve performance

Maxkeepaliverequests 100


# Keepalivetimeout:number of seconds to the ' next request '

# same client on the same connection.

#KeepAliveTimeout: In the same client connection, wait time for the next request.

KeepAliveTimeout 15


# # Server-pool Size Regulation (MPM specific)

# # General Server-pool server pool size (m per minute)


# threadsperchild:constant number of worker threads in the server process

Threadperchild: Number of threads working in the server process

# maxrequestsperchild:maximum number of requests a server process serves

Maximum number of requests per service process

<ifmodule mpm_winnt.c>

Threadsperchild 250

Maxrequestsperchild 0



# Listen:allows to bind Apache to specific IP addresses and/or

# ports, instead of the default. Also the <VirtualHost>

# directive.

#Listen: Allows you to bind Apache to a specified IP address or port, rather than the default port, please refer to the <VirtualHost> command

# Listen on specific IP addresses as shown below to

# prevent Apache glomming onto all bound IP addresses (

#像下面那样指定侦听的IP地址 to prevent Apache from seizing all bound IP addresses


Listen 80


# Dynamic Shared Object (DSO) Support


# to is able to use the functionality of a module which is built as a DSO you

# have to place corresponding ' LoadModule ' lines in this location so the

# directives contained in it are actually available _before_ they.

# statically compiled modules (those listed by ' httpd-l ') does not need

# to being loaded here.

#为了能够使用模块功能, modules are usually built in the form of DSO, you should use LoadModule line below, so that you can get instructions before using the function. Static compilation modules (as enumerated in httpd-1) do not need to be loaded here

# Example:

# LoadModule Foo_module modules/mod_foo.so


LoadModule Access_module modules/mod_access.so

LoadModule Actions_module modules/mod_actions.so

LoadModule Alias_module modules/mod_alias.so

LoadModule Asis_module modules/mod_asis.so

LoadModule Auth_module modules/mod_auth.so

#LoadModule Auth_anon_module modules/mod_auth_anon.so

#LoadModule Auth_dbm_module modules/mod_auth_dbm.so

#LoadModule Auth_digest_module modules/mod_auth_digest.so

LoadModule Autoindex_module modules/mod_autoindex.so

#LoadModule Cern_meta_module modules/mod_cern_meta.so

LoadModule Cgi_module modules/mod_cgi.so

#LoadModule Dav_module modules/mod_dav.so

#LoadModule Dav_fs_module modules/mod_dav_fs.so

LoadModule Dir_module modules/mod_dir.so

LoadModule Env_module modules/mod_env.so

#LoadModule Expires_module modules/mod_expires.so

#LoadModule File_cache_module modules/mod_file_cache.so

#LoadModule Headers_module modules/mod_headers.so

LoadModule Imap_module modules/mod_imap.so

LoadModule Include_module modules/mod_include.so

#LoadModule Info_module modules/mod_info.so

LoadModule Isapi_module modules/mod_isapi.so

LoadModule Log_config_module modules/mod_log_config.so

LoadModule Mime_module modules/mod_mime.so

#LoadModule Mime_magic_module modules/mod_mime_magic.so

#LoadModule Proxy_module modules/mod_proxy.so

#LoadModule Proxy_connect_module modules/mod_proxy_connect.so

#LoadModule Proxy_http_module modules/mod_proxy_http.so

#LoadModule Proxy_ftp_module modules/mod_proxy_ftp.so

LoadModule Negotiation_module modules/mod_negotiation.so

#LoadModule Rewrite_module modules/mod_rewrite.so

LoadModule Setenvif_module modules/mod_setenvif.so

#LoadModule Speling_module modules/mod_speling.so

#LoadModule Status_module modules/mod_status.so

#LoadModule Unique_id_module modules/mod_unique_id.so

LoadModule Userdir_module modules/mod_userdir.so

#LoadModule Usertrack_module modules/mod_usertrack.so

#LoadModule Vhost_alias_module modules/mod_vhost_alias.so

#LoadModule Ssl_module modules/mod_ssl.so


# Extendedstatus Controls whether Apache would generate ' full ' status

# information (Extendedstatus on) or just basic information (extendedstatus

# off, when the ' Server-status ' handler is called. The default is off.

#扩展状态控制Apache是否产生完整的状态信息 (set to ON), and if set to off generates basic information when associated with the Server-status header, the default value is off

#ExtendedStatus on

### Section 2: ' Main ' server configuration

#第二部分: Main service configuration

# The directives in this section set up the values used by the ' main '

# server, which responds to "any requests" aren ' t handled by a

# <VirtualHost> definition. These values also provide defaults for

# any <VirtualHost> containers your may define later in the file.

#本节中指令的设置值, will be used by the primary service, and the main service responds to requests that are not processed by the <VirtualHost>, which also provides a default value for the <VirtualHost> container, which you can define in the following file

# All of the directives may appear inside <VirtualHost> containers,

# in which case, these default settings are overridden for the

# virtual host being defined.

All of these directives will appear in the <VirtualHost> container, and these settings will be overwritten when the virtual host is defined.



# Serveradmin:your address, where problems with the server should is

# e-mailed. This is appears on some server-generated pages, such

# as Error documents. e.g. admin@your-domain.com

# ServerAdmin: Your address, when the system fails, you can send an email. This address appears on pages generated by the server, such as an error document. For example: admin@your-domain.com

ServerAdmin webmaster@moers.com


# ServerName gives the name and port that's the server uses to identify itself.

# This can often is determined automatically, but we recommend you specify

# It explicitly to prevent problems during startup.

#ServerNaem定义了server名称和端口号 to mark your identity. Usually can be defined automatically, it is recommended to explicitly define, avoid errors when starting

# If This isn't set to valid DNS name for your host, server-generated

# redirections won't work. Also the Usecanonicalname directive.

#如果没有正确定义主机的DNS, the server-generated redirection will not work while referencing the Usecanonicalname directive.

# If Your host doesn ' t have a registered DNS name, enter its IP addresses here.

# You'll have to access it ' anyway, and this'll make

# redirections work in a sensible way.

#如果你没有注册DNS名字, please enter the IP address here.

You can use IP addresses in any case, which also uses redirect to become sensitive

ServerName www.moers.com:80


# usecanonicalname:determines How Apache constructs self-referencing

# URLs and the server_name and Server_port variables.

# When set ' off ', Apache would use the Hostname and Port supplied

# by the client. When set ' on ', Apache would use the value of the

# ServerName directive.

#UseCanonicalName: Decide how APACEH constructs a custom reference URL, and server_name and Server_port variables

When set to OFF, Apache uses the domain name and port given by the client. When set to ON, Apache uses the servername directive

Usecanonicalname off


# Documentroot:the directory out of which your'll serve your

# documents. By default, all requests are taken from this directory, but

# Symbolic links and aliases may is used to the other locations.

#DocumentRoot: Server document placement directory. By default, all requests start here, except for tokens and aliases that will be referred to elsewhere.

DocumentRoot "C:/Program Files/apache group/apache2/htdocs"


# each directory to which Apache has access can is configured with respect

# to which services and features are allowed and/or disabled in

# directory (and its subdirectories).

#每个可供Apache访问的目录, can be configured to allow or disallow which services and features (including their subdirectories)

# Configure the ' default ' to be a very restrictive set of

# features.

#首先, we define a very strict default configuration


Options FollowSymLinks

AllowOverride None



# this ' from ' to ' forward you must specifically allow

# particular features to is enabled-so if something ' s not working as

# You might expect, make sure ' you have specifically enabled it

# below.

#注意, from this point forward, you have to license certain special features, so if certain features fail to do as you wish, make sure you enable this feature in the following.


# This should is changed to whatever your set DocumentRoot to.

# It's going to change the way you set the DocumentRoot

<directory "C:/Program files/apache Group/apache2/htdocs" >


# Possible values for the Options directive are ' None ', ' all ',

# or any combination of:

The possible values are none,all or any combination

# Indexes Includes followsymlinks symlinksifownermatch execcgi multiviews

# index includes followsymlinks symlinksifownermatch execcgi multiviews

# that ' MultiViews ' must be named *explicitly*---' Options all '

# doesn ' t give it to you.

#注意MultiViews被显式地Options all,

# The Options directive is both complicated and important. Please

# http://httpd.apache.org/docs-2.0/mod/core.html#options

# for more information.

#选项指令既复杂又重要 See http://httpd.apache.org/docs-2.0/mod/core.html#options for more information

Options Indexes FollowSymLinks


# AllowOverride Controls What directives may is placed in. htaccess files.

# It can be ' all ', ' None ', or any combination of the keywords:

# Options FileInfo authconfig Limit

#AllowOverride control What instructions can be added to the. htaccess, can be all,none, or combination of keywords

AllowOverride None


# Controls who can get stuff from this server.


Order Allow,deny

Allow from all



# userdir:the Name of the directory is appended onto a user ' s home

# directory If a ~user request is received. Be especially careful to use

# proper, forward slashes here. On Windows NT, "personal/my Website"

# is a more appropriate choice.

# Userdir: The name of the user's home, when a request to ~user is received.

Please be careful to use "/" properly. On the Winnt, "Personal/my Website" is a more appropriate choice.

Userdir "My documents/my Website"


# Control access to Userdir directories. The following is a example

# for a site where this directories are restricted to read-only.

#控制UserDir目录, here is an example of a directory that is read-only

# You must correct the path for the root to match your system ' s configured

# User directory location, e.g. "C:/winnt/profiles/*/my documents/my Website"

# or whichever, as appropriate.

#你必须更正root目录, to match the system settings, such as the user directory is C:/winnt/profiles/*/my documents/my website or other appropriate

#<directory "C:/Documents and settings/*/my documents/my Website" >

# allowoverride FileInfo authconfig Limit

# Options MultiViews Indexes symlinksifownermatch includesnoexec

# <limit Get POST OPTIONS propfind>

# Order Allow,deny

# Allow from all

# </Limit>

# <limitexcept Get POST OPTIONS propfind>

# Order Deny,allow

# Deny from all

# </LimitExcept>



# directoryindex:sets The file that Apache would serve if directory a

# is requested.

#DirectoryIndex: The Apache server will respond to the service as a directory

# The Index.html.var file (a type-map) is used to deliver content-

# negotiated documents. The MultiViews Option can be used for the

# same purpose, but it is a much slower.

#index. HTML variable file (a mapping) transmits the content directly. The MultiViews option can be used for the same purpose, but much slower

DirectoryIndex index.html Index.html.var


# accessfilename:the Name of the file to look for in each directory

# for additional configuration directives. Also the allowoverride

# directive.

#AccessFileName: The configuration file name used to find additional configuration directives under each directory, while referencing allowoverride (allow overloading) directives


Accessfilename. htaccess


# The following lines prevent htaccess and. htpasswd files from being

# viewed by WEB clients.

#下面两行, blocking Web Client access. htaccess and htpasswd (Access settings and Passwords) files


<files ~ "^\.ht" >

Order Allow,deny

Deny from all



# Typesconfig describes where the Mime.types file (or equivalent) is

# to be found.

# Typesconfig, describes where to find MIME type

Typesconfig Conf/mime.types


# DefaultType is the default MIME type the server would use for a document

# if it cannot otherwise determine one, such as from filename extensions.

If the server cannot determine the type of the document, the default MIME type is used, for example, depending on the extension

# If Your server contains mostly text or HTML documents, "Text/plain" is

# a good value. If Most of your content is binary, such as applications

# or images, want to use ' application/octet-stream ' instead to

# Keep browsers from trying to display binary files as though they are

# text.

#如果你的服务器主要包括text/html document, "Text/plain" is a good value. If most of your content is binary (binary), such as an application or a picture, you may want to use Application/octet-stream, which allows browsers to attempt to display binary data, although they are text

DefaultType Text/plain


# The Mod_mime_magic module allows the server to use various hints from the

# contents of the file itself to determine its type. The Mimemagicfile

# directive tells the module where the hint definitions are located.

# Mod_mime_magic module, which allows the server to identify file types based on content hints. The mimemagicfile instruction tells the module where to find the content hint.

<ifmodule mod_mime_magic.c>

Mimemagicfile Conf/magic



# Hostnamelookups:log the names of clients or just their IP addresses

# e.g., www.apache.org (ON) or (off).

# The default is off because it ' d being overall better for the net if people

# had to knowingly turn the feature on, since enabling it means

# Each client request would result in least one lookup request to the

# nameserver.

Hostnamelookups: Customer log or only its IP address, such as www.apache.org (on) or

(off). The default value is set to OFF, and if you want to put it on, it means that the first client request has to be queried at least once nameserver.


Hostnamelookups off


# Enablemmap:control Whether Memory-mapping is used to deliver

# files (assuming that the underlying OS supports it).

# the default is on; Turn this is serve from nfs-mounted

# filesystems. On some systems, turning it off (regardless of

# filesystem) can improve performance; For details, please

# Http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap

# Enablemmap: Controls whether files are routed through memory mappings (operating system support required)

The default value is on; If you use the NSF-loaded file system (usually under Linux), you should set off. On some systems, off, no matter what file system you use, to improve efficiency, see the documentation for details

#EnableMMAP off


# Enablesendfile:control whether the Sendfile kernel support is

# used to deliver files (assuming this OS supports it).

# the default is on; Turn this is serve from nfs-mounted

# filesystems. Please

# Http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile

# Enablesendfile: Controls whether kernel transfer files are supported (requires OS support). The default is on, if you are using NFS, use off

#EnableSendfile off


# errorlog:the location of the error log file.

# If You don't specify an ErrorLog directive within a <VirtualHost>

# container, error messages relating to that virtual host would be

# logged here. If you are *do* define an error logfile for a <VirtualHost>

# container, that host ' s errors'll be logged there and.

#ErrorLog: Error log file

If you want to define a errorlog directive for a virtual host, the error message for that virtual host will be logged here

ErrorLog Logs/error.log


# Loglevel:control The number of messages logged to the Error.log.

# Possible values Include:debug, info, notice, warn, error, crit,

# Alert, Emerg.

# Loglever: Log level, (similar to log4j, translator), determine which level of error information will be recorded, such as Debug,info,notice,warn,error, Crit,alert,emerg, etc., at the set level of information will be recorded ( Translator note).

LogLevel warn


# The following directives define some format nicknames for use with

# a Customlog directive (below).

# Log format (similar to log4j)

Logformat "%h%l%u%t \%r\"%>s%b \ "%{referer}i\" \ "%{user-agent}i\" "combined

Logformat "%h%l%u%t \"%r\ "%>s%b" common

Logformat "%{referer}i->%u" Referer

Logformat "%{user-agent}i" Agent

# You need to enable MOD_LOGIO.C to use%I and%o

#LogFormat "%h%l%u%t \%r\"%>s%b \ "%{referer}i\" \ "%{user-agent}i\"%I%o "Combinedio

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.