首页 > 网站 > Apache > 正文

Apache HTTP最新官方配置(中译版)

2024-08-27 18:29:11
字体:
来源:转载
供稿:网友

  文章简介:apache最新官方配置文件中文版。帮忙web服务器管理员更方便的对apache进行配置。

#

# based upon the ncsa server configuration files originally by rob mccool.

#参照ncsa服务器的配置文件,原版由rob mccool发布

#

# this is the main apache server configuration file.  it contains the

# configuration directives that give the server its instructions.

# see <url:http://httpd.apache.org/docs-2.0/> for detailed information about

# the directives.

#这是apache server的主配置文件. 它包含配置指令,来指示服务器

#请参考 http://httpd.apache.org/docs-2.0 了解关于指令的详细信息

# do not simply read the instructions in here without understanding

# what they do.  they're here only as hints or reminders.  if you are unsure

# consult the online docs. you have been warned. 

#不要仅仅是阅读本指令,而应该理解指令做了什么。在这里仅起提示的作用。

#如果你不清楚请参阅在线文档。特别提示

# 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. 控制apache server的全局操作的指令(全局环境变量).

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

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

#     these directives also provide default values for the settings

#     of all virtual hosts.

#  2.配置主服务或者默认服务的指令,它针对那些被虚拟主机以外的请求作出响应.

#    它也包含虚拟主机的一些默认参数

#  3. settings for virtual hosts, which allow web requests to be sent to

#     different ip addresses or hostnames and have them handled by the

#     same apache server process.

#  3. 虚拟主机设置,这使得发往不同的ip或者主机名的请求可以被子同一个apache服务#     器处理

# configuration and logfile names: if the filenames you specify for many

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

# server will 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" will be interpreted by the

# server as "c:/program files/apache group/apache2/logs/foo.log".

#配置和日志文件名:如果你所指定的文件名以”/”(在win32中以盘符:/)开头,服务器将以绝对路径来处理。如果不以”/”开头,则以相对于serverroot不解释,所以对于logs/foo.log来讲,当serverroot为"c:/program files/apache group/apache2”时,则指的是

c:/program files/apache group/apache2/logs/foo.log文件

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

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

注意,在文件名的定义中,必须用正斜杠,而不是反斜杠,如c:/apache而不是c:/apache

# if a drive letter is omitted, the drive on which apache.exe is located

# will be used by default.  it is recommended that you always supply

# an explicit drive letter in absolute paths, however, to avoid

# confusion.

#如果省略了盘符,则以apache.exe所在的盘符为默认值

建议在绝对路径中永远使用显式的盘符,这样有助于消除误解

 

### 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服务器,例如它所能处理的并发请求数或者它在哪里能够找到其配置文件

 

#

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

# configuration, error, and log files are kept.

# serverroot: 服务器的配置,错误和日志文件的根目录

# note!  if you intend to place this on an 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 will save yourself a lot of trouble.

#注意:如果将其保存到nfs上或者网络上mounted的文件系统上,然后应该阅读lockfile文档,http://httpd.apache.org/docs-2.0/mod/mpm_common.html#lockfile,将能解决你的很多麻烦.

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

#不要在目录的末尾加上斜杠

serverroot "c:/program files/apache group/apache2"

serverroot:根目录

#

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

# if unspecified (the default), the scoreboard will be stored in an

# anonymous shared memory segment, and will be unavailable to third-party

# applications.

scoreboardfile: 保存服务器内部的处理信息

如果未定议(默认状态),scoreboard将被保存在匿名的共享内存段中,并且对于第三方来讲,是不可获得的

# if specified, ensure that no two invocations of apache share the same

# scoreboard file. the scoreboard file must be stored on a local disk.

#如果已定义,应确保apache的两个调用不能共享同一个scoreboard. scoreboard文件必须存放在可分配的磁盘上

#scoreboardfile logs/apache_runtime_status

 

#

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

# identification number when it starts.

#pidfile:当服务器起努时,服务器需要将其进程id号存放在此文件中

pidfile logs/httpd.pid

 

#

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

#timeout:接收和发送数据的超时设置,秒数

timeout 300

 

#

# keepalive: whether or not to allow persistent connections (more than

# one request per connection). set to "off" to deactivate.

#keepalive: 是否支持持久联接(而不是每个请求建一个连接),设off关闭此功能

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 leave this number high, for maximum performance.

#maxkeepaliverequests:在持久连接期间,所允许的最大请求数量。设为0表示不作限制

建议设为较高的数,以提高性能

maxkeepaliverequests 100

 

#

# keepalivetimeout: number of seconds to wait for the next request from the

# same client on the same connection.

#keepalivetimeout:在同一个客户连接中,等待下一个请求的等待时间。

keepalivetimeout 15

 

##

## server-pool size regulation (mpm specific)

## 常规server-pool服务器池的大小(每分钟m数)

 

# winnt mpm winnt 的mpm

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

threadperchild:服务器进程中工作的线程数量

# maxrequestsperchild: maximum  number of requests a server process serves

每个服务进程的最大请求数

<ifmodule mpm_winnt.c>

threadsperchild 250

maxrequestsperchild  0

</ifmodule>

 

#

# listen: allows you to bind apache to specific ip addresses and/or

# ports, instead of the default. see also the <virtualhost>

# directive.

#listen:允许你将apache绑定到指定的ip地址或端口,而不是默认端口,请同时参考<virtualhost>指令

# change this to listen on specific ip addresses as shown below to

# prevent apache from glomming onto all bound ip addresses (0.0.0.0)

#像下面那样指定侦听的ip地址,防止apache抢占所有绑定的ip地址

#listen 12.34.56.78:80

listen 80

 

#

# dynamic shared object (dso) support

#动态共享对象支持dso

# to be able to use the functionality of a module which was built as a dso you

# have to place corresponding `loadmodule' lines at this location so the

# directives contained in it are actually available _before_ they are used.

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

# to be loaded here.

#为了能够使用模块功能,模块通常以dso的方式构建,你应该在下面使用loadmodule行,使得能够在使用前获得指令的功能。静态编译模块(在httpd-1中所列举的)不需要在此装载

# 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 will generate "full" status

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

# off) when the "server-status" handler is called. the default is off.

#扩展状态控制apache是否产生完整的状态信息(设为on产生全部),如果设为off则产生基本的信息,当与server-status头有关,默认值为off

#extendedstatus on

 

### section 2: 'main' server configuration

#第二部分:主服务配置

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

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

# <virtualhost> definition.  these values also provide defaults for

# any <virtualhost> containers you may define later in the file.

#本节中指令的设置值,将被主服务所使用,主服务响应那些没有被<virtualhost>所处理的请求,这些值也为<virtualhost>容器提供了默认值,你可以在后面的文件中定义

# all of these directives may appear inside <virtualhost> containers,

# in which case these default settings will be overridden for the

# virtual host being defined.

所有这些指令将出现在<virtualhost>容器中,这些设定值将在定义virtual host时被覆写。

#

 

#

# serveradmin: your address, where problems with the server should be

# e-mailed.  this address appears on some server-generated pages, such

# as error documents.  e.g. [email protected]

# serveradmin:你的地址,当系统故障时,可以给你发email。此地址出现在那些由服务器生成的页面上,如出错文档。例如:[email protected]

serveradmin [email protected]

 

#

# servername gives the name and port that the server uses to identify itself.

# this can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#servernaem定义了server名称和端口号,用以标明自己的身份。通常可以自动定义,建议显式地定义,避免起动时出错

# if this is not set to valid dns name for your host, server-generated

# redirections will not work.  see also the usecanonicalname directive.

#如果没有正确定义主机的dns,服务器产生的重定向将不会工作,同时参考usecanonicalname指令。

# if your host doesn't have a registered dns name, enter its ip address here.

# you will have to access it by its address anyway, and this will make

# redirections work in a sensible way.

#如果你没有注册dns名字,请在这里输入ip地址。

你可以在任何情况下使用ip地址,这也使用得重定向变得敏感

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 will use the hostname and port supplied

# by the client.  when set "on", apache will use the value of the

# servername directive.

#usecanonicalname:决定apaceh如何构建自定参考url,和server_name及server_port变量

当设为off时,apache将使用客户端给出的域名和端口。当设为on时,apache将使用servername指令

usecanonicalname off

 

#

# documentroot: the directory out of which you will serve your

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

# symbolic links and aliases may be used to point to other locations.

#documentroot:服务器文档放置目录。在默认情形下,所有的请求都从这里开始,除了记号和别名将改指它处以外。

documentroot "c:/program files/apache group/apache2/htdocs"

 

#

# each directory to which apache has access can be configured with respect

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

# directory (and its subdirectories).

#每个可供apache访问的目录,可以配置成允许或禁止哪些服务和特征(包括其子目录)

# first, we configure the "default" to be a very restrictive set of

# features. 

#首先,我们定义一个默认的非常严格的配置

<directory />

    options followsymlinks

    allowoverride none

</directory>

 

#

# note that from this point forward you must specifically allow

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

# you might expect, make sure that you have specifically enabled it

# below.

#注意,从这一点往前,你必须许可某些特殊的功能,所以如果某些功能未能如你所愿,要确保你在在下述中启用了该功能。

 

#

# this should be changed to whatever you set documentroot to.

# 这将改变你对documentroot的设置

<directory "c:/program files/apache group/apache2/htdocs">

 

#

# possible values for the options directive are "none", "all",

# or any combination of:

可能的值为none,all或者任意组合

#   indexes includes followsymlinks symlinksifownermatch execcgi multiviews

# 索引包括followsymlinks symlinksifownermatch execcgi multiviews

# note 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 see

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

# for more information.

#选项指令既复杂又重要,请参阅http://httpd.apache.org/docs-2.0/mod/core.html#options了解详情

    options indexes followsymlinks

 

#

# allowoverride controls what directives may be placed in .htaccess files.

# it can be "all", "none", or any combination of the keywords:

#   options fileinfo authconfig limit

#allowoverride 控制什么指令能够加入到.htaccess中,可以是all,none,或者组合关键字

    allowoverride none

 

#

# controls who can get stuff from this server.

#控制谁可以可以访问此服务

    order allow,deny

    allow from all

 

</directory>

 

#

# userdir: the name of the directory that 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: 用户的home的名称,当接到到~user的请求时。

请小心正确使用”/”. 在winnt上,”personal/my website”是更合适的选择

userdir "my documents/my website"

 

#

# control access to userdir directories.  the following is an example

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

#控制userdir目录,以下是一个例子,这个目录是只读的

# 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目录,与系统设置相配,如用户目录是c:/winnt/profiles/*/my documents/my website或者其它合适的

#<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>

#</directory>

 

#

# directoryindex: sets the file that apache will serve if a directory

# is requested.

#directoryindex: apache服务器将要以一个目录的形式响应服务

# 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 much slower.

#index.html变量文件(一种映射)将直接传送内容。multiviews选项可以用于同样的目的,但是要慢得多

directoryindex index.html index.html.var

 

#

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

# for additional configuration directives.  see also the allowoverride

# directive.

#accessfilename: 用来查找各个目录下额外的配置指令的配置文件名,同时参考allowoverride(允许重载)指令

#acce

accessfilename .htaccess

 

#

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

# viewed by web clients.

#下面两行,阻址web客户端访问 .htaccess和htpasswd(访问设定和密码)的文件

#

<files ~ "^/.ht">

    order allow,deny

    deny from all

</files>

 

#

# typesconfig describes where the mime.types file (or equivalent) is

# to be found.

# typesconfig,描述在何处找到mime型别

typesconfig conf/mime.types

 

#

# defaulttype is the default mime type the server will use for a document

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

如果服务器不能确定文档的型别,将使用默认的mime型别,例如根据扩展名

# 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, you may want to use "application/octet-stream" instead to

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

# text.

#如果你的服务器主要包括text/html文档,”text/plain”就是一个好的取值。如果你的大多数内容是binary(二进制)的,如应用程序或图片,你可能希望使用application/octet-stream,使得浏览器试图显示二进制数据,尽管它们是文本

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模块,允许服务器根据内容提示来识别文件型别。mimemagicfile指令告知模块“内容提示”应到何处找。

<ifmodule mod_mime_magic.c>

    mimemagicfile conf/magic

</ifmodule>

 

#

# hostnamelookups: log the names of clients or just their ip addresses

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

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

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

# each client request will result in at least one lookup request to the

# nameserver.

hostnamelookups: 客户日志或者仅其ip地址,如www.apache.org(on) 或者204.62.129.132

(off).默认为值设为off比较好,如果希望将此置为on将意味着第一次客户请求都至少要查询一次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 off if you serve from nfs-mounted

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

# filesystem) can improve performance; for details, please see

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

# enablemmap: 控制是否通过内存映射的方式传送文件(须得操作系统支持)

默认值为on; 如果你使用nsf加载的文件系统(通常在linux下),应置为off. 在某些系统上,置off,不管使用什么文件系统,能够提高效率,详细情况,请参阅文档

#enablemmap off

 

#

# enablesendfile: control whether the sendfile kernel support is

# used  to deliver files (assuming that the os supports it).

# the default is on; turn this off if you serve from nfs-mounted

# filesystems.  please see

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

# enablesendfile: 控制内核传送文件是否支持(需要os支持)。默认为on,如果使用nfs,则使用off

#enablesendfile off

 

#

# errorlog: the location of the error log file.

# if you do not specify an errorlog directive within a <virtualhost>

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

# logged here.  if you *do* define an error logfile for a <virtualhost>

# container, that host's errors will be logged there and not here.

#errorlog: 出错日志文件

如果你想为虚拟主机定义errorlog指令,则该虚拟主机的错误信息将被记录到这里

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: 日志等级,(与log4j相似,译者注),决定哪些级别的出错信息将被记录,如debug,info,notice,warn,error, crit,alert,emerg等,在设定级别以上的信息就会被记录(译者注).

loglevel warn

 

#

# the following directives define some format nicknames for use with

# a customlog directive (see below).

# 日志格式(与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

  • 网站运营seo文章大全
  • 提供全面的站长运营经验及seo技术!
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表