Apache httpd.conf配置文件 2(Main server configuration)

时间:2023-11-17 22:44:38

### Section 2'Main' server configuration

#

# The directives in this section set up the values used by the 'main'     本节的指令集用来设置“main"服务器所使用的值

# server, which responds to any requests that aren't handled by a     服务器响应任何没有被<VirtualHost>定义所处理的请求.

# <VirtualHost> definition.  These values also provide defaults for        这些值也为任何稍后你可能在下面定义的

# any <VirtualHost> containers you may define later in the file.            <VirtualHost>容器提供默认值

#

# All of these directives may appear inside <VirtualHost> containers,    所有的标识可能会在<VirtualHost>中出现

# in which case these default settings will be overridden for the            这些默认设置会被虚拟主机重新定义覆盖

# virtual host being defined.

#

#

# ServerAdmin: Your address, where problems with the server should be   你的邮件地址,出现问题时系统会给你发邮件

# e-mailed.  This address appears on some server-generated pages, such   地址会出现在server-generated页面上,作为错误文档

# as error documents.  e.g. admin@your-domain.com                                 例如   admin@your-domain.com

#

ServerAdmin root@localhost

#

# ServerName gives the name and port that the server uses to identify itself.       ServerName 规定了名字和端口用于让系统识别自身

# This can often be determined automatically, but we recommend you specify      这通常是自动决定的,但是我们推荐你明确的指定,

# it explicitly to prevent problems during startup.                                                   防止启动时出错。

#

# If this is not set to valid DNS name for your host, server-generated      如果为你的主机指定了一个无效的DNS名,server-generated

# redirections will not work.  See also the UseCanonicalName directive.   重定向将不会工作,参见UseCanonicalName指令

#                                                                                                           (此指令在下方五行处)

# If your host doesn't have a registered DNS name, enter its IP address here. 如果你的主机没有一个注册的DNS名称,在这里输入IP地址

# You will have to access it by its address anyway, and this will make    无论如何,你必须使用它的IP地址来工作,

# redirections work in a sensible way.                                                   这里使用一种容易理解的方式进行重定向服务

#

#ServerName www.example.com:80                                  (设置apache默认站点名称和端口号,可以为ip或域名)

# (是否使用标准名称)

# UseCanonicalName: Determines how Apache constructs self-referencing  决定Apache如何构造自我重定向的

# URLs and the SERVER_NAME and SERVER_PORT variables                   URLS和 SERVER_NAME 和 SERVER_PORT 变量。

# When set "Off", Apache will use the Hostname and Port supplied 当设置为 “Off”时,Apache会使用用户端提供的主机名和端口号

# by the client.  When set "On", Apache will use the value of the    当设置为“On”,Apache会使用ServerName指令的值

# ServerName directive.  (举例:ServerName值为www.abc.com  当用户输入http://www.index.html 值为Off时相当于http://www.index.html)

#                                                                                                                                         值为On时相当于http://www.abc.com/index.html

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 "/var/www/html"                                         文档根目录为:/var/www/html

#

# Each directory to which Apache has access can be configured with respect   Apache访问的每个目录可设置相关的服务和特性是
# to which services and features are allowed and/or disabled in that       允许或(和)不允许

# directory (and its subdirectories).                                                        (同样影响其子目录)

#

# First, we configure the "default" to be a very restrictive set of      首先,我们配置“默认”为一个高限制的特征

# features.

#

<Directory />                   根目录访问控制

    Options FollowSymLinks   允许跟随符合连接(可以连接到目录以外的文件)

    AllowOverride None          不允许覆盖

</Directory>

FollowSymLinks表示允许在此目录使用符号连接

在 AllowOverride 设置为 None 时, .htaccess 文件将被完全忽略。
当此指令设置为 All 时,所有具有 “.htaccess” 作用域的指令都允许出现在 .htaccess 文件中

#

# Note that from this point forward you must specifically allow  注意从这里开始你一定要明确地允许哪些特别的特征能够被使用

# particular features to be enabled - so if something's not working as所以,如果Apache没有象你所期待的那样工作的话,

# you might expect, make sure that you have specifically enabled it   请检查你是否在下面明确的指定它可用

# below.

#

#

# This should be changed to whatever you set DocumentRoot to.       这里可以改变你的文档根目录

#

<Directory "/var/www/html">

#                                                                                Options主要作用是控制特定目录将启用哪些服务器特性

# Possible values for the Options directive are "None", "All",      Options:这个指令的值可以是“None”,“All”,

# or any combination of:                                                          或者下列选项的任意组合

#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews  

#  允许目录清单  允许ssi   符号连接       允许浏览其他目录 所有者匹配    多种资源协商

# Note that "MultiViews" must be named *explicitly* --- "Options All"                     注意,“MultiViews”必须被显式的指定,

# doesn't give it to you.       “Options All”不能为你提供这个特性

#

# The Options directive is both complicated and important.  Please see  这个指令既复杂又重要,请参见

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

# for more information.

#

Options Indexes FollowSymLinks

 Indexes 的作用就是当该目录下没有 index.html 文件时,就显示目录结构
去掉 Indexes,Apache 就不会显示该目录的列表了

#

# AllowOverride controls what directives may be placed in .htaccess files.  AllowOverride控制那些被放置在.htaccess文件中的指令

# It can be "All", "None", or any combination of the keywords:                 它可以是“All”,“None”,或者下列指令的组合

#   Options FileInfo AuthConfig Limit

#

    AllowOverride None
     AllowOverride None表示不允许这个目录下的访问控制文件来改变这里的配置
     这也意味着不用查看这个目录下的访问控制文件

#

# Controls who can get stuff from this server.    控制谁可以获得服务

#

Order allow,deny

    Allow from all

Order 对页面的访问控制顺序 后面的一项是默认选项,如allow,deny则默认是deny
    Allow from all 表示允许所有的用户,通过和上一项   结合可以控制对网站的访问控制

</Directory>

# (个人主页的设置)

# UserDir: The name of the directory that is appended onto a user's home    当请求~user时,追加到用户主目录的路径地址

# directory if a ~user request is received.

#

# The path to the end user account 'public_html' directory must be 用户账户的'public_html'目录路径

# accessible to the webserver userid.  This usually means that ~userid必须允许访问web服务器用户id,这通常意味着userid必须拥有777权限

# must have permissions of 711, ~userid/public_html must have permissions~userid/public_html必须拥有755权限

# of 755, and documents contained therein must be world-readable. 包含的文档必须能够被任何用户阅读

# Otherwise, the client will only receive a "403 Forbidden" message. 否则,客户端会收到403 Forbidden 的信息

#

# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden       参考网址……

#

<IfModule mod_userdir.c>

#

# UserDir is disabled by default since it can confirm the presence 用户目录默认设置时禁用的 它可以确认系统

# of a username on the system (depending on home directory   存在的用户名,(根据主目录的权限)

# permissions).

#

  UserDir disabled         用户个人主页功能禁用

可以如下设置:
 UserDir enabled peter test      <====这里只允许peter和test这两个用户可以实现个人主页

#

# To enable requests to /~user/ to serve the user's public_html        若要启用 /~user/服务 用户目录

# directory, remove the "UserDir disabled" line above, and uncomment    如果允许访问用户的 /~user/目录中的网页文件

# the following line instead:                                                                       则取消以上注释,并对其中进行修改

#

    #UserDir public_html    指明个人主页的文档根目录名称为……

</IfModule>       当访问www.abc.com/~s1 时  相当于访问站点中的  /home/s1/public_html/index.html    即s1个人主页

#

# Control access to UserDir directories.  The following is an example     控制访问用户目录,下面是一个例子

# for a site where these directories are restricted to read-only.              目录权限为只读

#

#<Directory /home/*/public_html>

#    AllowOverride FileInfo AuthConfig Limit             FileInfo    允许使用控制文档类型的指令

AuthConfig  允许使用与认证授权相关的指令

Limit     允许使用控制主机访问的指令(Allow, Deny, Order)

#    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

#    <Limit GET POST OPTIONS>

#        Order allow,deny

#        Allow from all

#    </Limit>

#    <LimitExcept GET POST OPTIONS>

#        Order deny,allow

#        Deny from all

#    </LimitExcept>

#</Directory>

#   (指定每个目录的默认文档名)

# DirectoryIndex: sets the file that Apache will serve if a directory 定义请求是一个目录时,Apache向用户提供服务的文件名

# is requested.

#

# The index.html.var file (a type-map) is used to deliver content- index.html.var  内容协商文档用于提供一个文档处理列表

# negotiated documents.  The MultiViews Option can be used for the   出于同样的目的,也可以使用MultiViews选项,

# same purpose, but it is much slower.                                      但是它会非常慢

#

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.                                                                                           参考AllowOverride 指令

#

AccessFileName .htaccess                             加载分布式访问控制的文件

#

# The following lines prevent .htaccess and .htpasswd files from being  下面的行防止.htaccess和.htpasswd文件

# viewed by Web clients.      被Web客户查看(以 .ht开头的文件进行访问控制)

#

<Files ~ "^\.ht">

Order allow,deny

Deny from all                 这里为禁止访问.ht开头的文件

Satisfy All        为ALL要求同时满足两个条件才可以访问。当设置Satisfy值为Any时,则只要满足一个就可以了(如下)

</Files>

在Apache的访问控制中,有两种机制,一是客户端限制,一是用户验证机制。解释一下:

客户端限制:

<Directory /some/dir>

order allow,deny

deny from all

</Directory >

这就是一个目录限制,他限制所有IP对这个目录的访问。

用户验证机制:

<Directory /some/dir>

AuthType Basic

AuthName "My Auth File"

AuthUserFile /some/file/path

Require valid-user

</Directory >

这就是一个用户验证机制,他要求用户给出用户名和密码才能访问目录下的内容。

#

# TypesConfig describes where the mime.types file (or equivalent) is  TypesConfig 描述了寻找mime.types类型文件的路径

# to be found.           指定mime.types文件的存放位置

#

TypesConfig /etc/mime.types

#

# DefaultType is the default MIME type the server will use for a document  DefaultType定义当不能确定MIME类型时,服务器提供的

# if it cannot otherwise determine one, such as from filename extensions. 默认MIME类型,例如文件扩展名

# If your server contains mostly text or HTML documents, "text/plain" is 如果你的服务器主要包含text或HTML文档,text/plain是一个好的

# 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 application/octet-stream 防止浏览器像显示文本一样显示二进制文件

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

# text.

#

DefaultType text/plain            指定默认的文件类型

#

# The mod_mime_magic module allows the server to use various hints from themod_mime_magic 模块允许服务器使用各种线索

# contents of the file itself to determine its type.  The MIMEMagicFile 从自己文档目录中决定类型,The MIMEMagicFile指令

# directive tells the module where the hint definitions are located.  定义hints定义所在的文件

#

<IfModule mod_mime_magic.c>

#   MIMEMagicFile /usr/share/magic.mime

 MIMEMagicFile conf/magic                    通过该模块使得server可以按照文件内容中的各种提示信息来决定文件的类型

</IfModule>

#

# HostnameLookups: Log the names of clients or just their IP addresses  记录客户端的名字或者是IP

# e.g., www.apache.org (on) or 204.62.129.132 (off). 例如  选项为on记录主机名 选项为off记录IP

# The default is off because it'd be overall better for the net if people 默认设置为off,因为它整体对于网络更好,如果不得不设置为on

# 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 Off      这选项是配置  access_log 访问日志中  是否记录访客的名字;也可以两者都记录但会增加负载

#

# EnableMMAP: Control whether memory-mapping is used to deliver 控制是否进行内存转储用于文件

# files (assuming that the underlying OS su控制是否使用sendfile kernel支持发送文件 pports it).   (假如服务器支持它的话)

# The default is on; turn this off if you serve from NFS-mounted 默认值为on,设置为off如果你的服务器安装在网络文件系统上(NFS)

# filesystems.  On some systems, turning it off (regardless of 在一些系统上,关闭它可以提升性能

# filesystem) can improve performance; for details, please see 更多细节,请查看……

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

#

#EnableMMAP off

#

# EnableSendfile: Control whether the sendfile kernel support is  控制是否使用sendfile内核支持发送文件

# used to deliver files (assuming that the OS supports it).(假如服务器支持它的话)

# The default is on; turn this off if you serve from NFS-mounted 默认值为on,如果你的服务器安装在网络文件系统 
# (NFS)上,请你关闭它

# filesystems.  Please see   参考更多……

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

#

#EnableSendfile off

#

# ErrorLog: The location of the error log file.     错误日志文件位置

# If you do not specify an ErrorLog directive within a <VirtualHost>如果你没有在<VirtualHost>内定义ErrorLog指令

# 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 logs/error_log

#

# LogLevel: Control the number of messages logged to the error_log.控制记录在错误日志文件中的日志信息数量

# Possible values include: debug, info, notice, warn, error, crit,可能的选项值包括: debug, info, notice, warn, error, crit

# alert, emerg.alert, emerg

#

LogLevel warn     日志记录的级别

#

# The following directives define some format nicknames for use with 下面的指令定义了一些别名 用于日志格式

# a CustomLog directive (see below).

#     下面是定义 访问日志 记录的数据格式   和格式的名称

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

# "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this combinedio包括实际接收和发送的数量和字节

# requires the mod_logio module to be loaded.这需要加载 mod_logio 模块

#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

#

# The location and format of the access logfile (Common Logfile Format). 访问日志文件的位置和格式

# If you do not define any access logfiles within a <VirtualHost> 如果你没有在<VirtualHost>内定义这个指令,传输信息将记录在这里

# container, they will be logged here.  Contrariwise, if you *do* 相反,如果你定义了虚拟主机访问日志位置,

# define per-<VirtualHost> access logfiles, transactions will be  传输信息会记录在那里而不是这里

# logged therein and *not* in this file.

#

#CustomLog logs/access_log common         定义访问日志存储位置 和 以哪种格式存储

#

# If you would like to have separate agent and referer logfiles, uncomment 如果你想分开记录代理和来源链接信息

# the following directives.   取消下列指令的备注符号

#

#CustomLog logs/referer_log referer

#CustomLog logs/agent_log agent

#

# For a single logfile with access, agent, and referer information 使用一个文件记录access, agent, referer信息 (复合日志文件格式)

# (Combined Logfile Format), use the following directive:  使用下列指令

#

CustomLog logs/access_log combined

#

# Optionally add a line containing the server version and virtual host  添加包含 服务器版本 和 虚拟主机名字 的一行信息

# name to server-generated pages (internal error documents, FTP directory 到server-generated输出页中 (内部错误文档,FTP目录列表,

# listings, mod_status and mod_info output etc., but not CGI generated  mod_status和mod_info输出等,但是不包括CGI错误

# documents or custom error documents).  和自定义的错误文档)

# Set to "EMail" to also include a mailto: link to the ServerAdmin.    设为“EMail”将包含一个指向ServerAdmin的 mailto连接

# Set to one of:  On | Off | EMail    可以为如下值:On | Off | EMail

#

ServerSignature On

#

# Aliases: Add here as many aliases as you need (with no limit). The format is   在这里无限制添加你需要的别名,格式是

# Alias fakename realname    Alias  别名 真实名

#

# Note that if you include a trailing / on fakename then the server will  注意,如果你在别名的未尾包含了“/”,那么在URL中也需要包含“/”

# require it to be present in the URL.  So "/icons" isn't aliased in this   因此,“/icons”不是这个示例中的别名,而应该是 "/icons/"

# example, only "/icons/".  If the fakename is slash-terminated, then the   如果别名在结尾有斜线,那么真名结尾也要有斜线

# realname must also be slash terminated, and if the fakename omits the  如果别名省略了末尾斜线,真名也必须省略它

# trailing slash, the realname must also omit it.

#

# We include the /icons/ alias for FancyIndexed directory listings.  If you 我们使用别名“/icons/”来表示FancyIndexed目录列表

# do not use FancyIndexing, you may comment this out.  如果你不使用FancyIndexing,你可以注释掉它

#

Alias /icons/ "/var/www/icons/"     定义icons   为 var/www/icons/ 的别名

<Directory "/var/www/icons">        一般后面紧跟对该目录的访问控制配置

    Options Indexes MultiViews FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

#

# WebDAV module configuration section. WebDAV模块配置部分

#一种基于 HTTP 1.1协议的通信协议。它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法

#使应用程序可直接对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制

<IfModule mod_dav_fs.c>              

    # Location of the WebDAV lock database.    激活后,允许客户端通过web方式维护站点内容

    DAVLockDB /var/lib/dav/lockdb                   指定WebDAV加锁数据库的位置

</IfModule>

#

# ScriptAlias: This controls which directories contain server scripts.  ScriptAlias:服务器脚本别名控制目录

# ScriptAliases are essentially the same as Aliases, except that  脚本别名本质上和别名是一样的,除了真名目录的文档是CGI脚本程序

# documents in the realname directory are treated as applications and  以及服务器会运行当请求而不是文档发送到客户端时

# run by the server when requested rather than as documents sent to the client.

# The same rules about trailing "/" apply to ScriptAlias directives as to 同样的 斜杠 规则适用于脚本别名指令和前面别名一样

# Alias.

#

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

#

# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased  var/www/cgi-bin路径应该改变的和脚本别名CGI目录一致

# CGI directory exists, if you have that configured.  如果你曾配置过

#

<Directory "/var/www/cgi-bin">

    AllowOverride None

    Options None

    Order allow,deny

    Allow from all

</Directory>

#

# Redirect allows you to tell clients about documents which used to exist in  Redirect允许你告诉客户端使用存在于服务器命名空间中的文档

# your server's namespace, but do not anymore. This allows you to tell the    但是不是

# clients where to look for the relocated document.  允许你告诉客户端去哪里找到重定位文档

# Example:  例如    将  /foo 目录 重定向到http://www.example.com/bar    并告知用户该资源永久改变,返回状态码301

# Redirect permanent /foo http://www.example.com/bar

#

# Directives controlling the display of server-generated directory listings.  控制server-generated目录列表显示的指令

#

#

# IndexOptions: Controls the appearance of server-generated directory   IndexOptions:控制server-generated目录列表显示特征

# listings.

#

IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8

FancyIndexing 每种文件前加一个小图标以示区别

VersionSort      对同一个软件的多个版本进行排序

NameWidth=* HTMLTable Charset=UTF-8      文件名字段自动适应当前目录下的最长文件名

#

# AddIcon* directives tell the server which icon to show for different  AddIcon* 指令告诉服务器不同扩展名的文件图标如何显示

# files or filename extensions.  These are only displayed for   这里仅显示FancyIndexed 目录

# FancyIndexed directories.

#

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

 

AddIconByType (TXT,/icons/text.gif) text/*

AddIconByType (IMG,/icons/image2.gif) image/*

AddIconByType (SND,/icons/sound2.gif) audio/*

AddIconByType (VID,/icons/movie.gif) video/*

 

AddIcon /icons/binary.gif .bin .exe       指定服务器通过文件的扩展名来显示图标

AddIcon /icons/binhex.gif .hqx

AddIcon /icons/tar.gif .tar

AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv

AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip

AddIcon /icons/a.gif .ps .ai .eps

AddIcon /icons/layout.gif .html .shtml .htm .pdf

AddIcon /icons/text.gif .txt

AddIcon /icons/c.gif .c

AddIcon /icons/p.gif .pl .py

AddIcon /icons/f.gif .for

AddIcon /icons/dvi.gif .dvi

AddIcon /icons/uuencoded.gif .uu

AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl

AddIcon /icons/tex.gif .tex

AddIcon /icons/bomb.gif core

 

AddIcon /icons/back.gif ..

AddIcon /icons/hand.right.gif README

AddIcon /icons/folder.gif ^^DIRECTORY^^

AddIcon /icons/blank.gif ^^BLANKICON^^

#

# DefaultIcon is which icon to show for files which do not have an icon  DefaultIcon 为那些没有显式定义图标的文件提供处理

# explicitly set.

#AddDescription允许你在server-generated索引后放置一个简短的说明

DefaultIcon /icons/unknown.gif     定义默认图标

#

# AddDescription allows you to place a short description after a file in     AddDescription允许你在server-generated索引后放置一个简短的说明

# server-generated indexes.  These are only displayed for FancyIndexed   只对FancyIndexed指令有效

# directories.

# Format: AddDescription "description" filename    格式 AddDescription "说明" 文件名

#

#AddDescription "GZIP compressed document" .gz  

#AddDescription "tar archive" .tar

#AddDescription "GZIP compressed tar archive" .tgz

#

# ReadmeName is the name of the README file the server will look for by  ReadmeName指定服务器默认查找的README文件的名字

# default, and append to directory listings.   并添加到目录列表

#

# HeaderName is the name of a file which should be prepended to    HeaderName指定目录列表前缀文件的文件名

# directory indexes.

ReadmeName README.html       在进行目录列表时,将位于该目录下的readme.html内容追缴的目录列表末尾

HeaderName HEADER.html         在进行目录列表时,将位于该目录下的header.html内容追缴的目录列表开头

 

#

# IndexIgnore is a set of filenames which directory indexing should ignore   IndexIgnore指定目录索引忽略并且不包含在列表中的文件名集合

# and not include in the listing.  Shell-style wildcarding is permitted.   支持shell类型的通配符

#

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t      定义哪些文件名不参与索引

#

# DefaultLanguage and AddLanguage allows you to specify the language of  DefaultLanguage和AddLanguage允许你指定文档的语言

# a document. You can then use content negotiation to give a browser a    你可以用内容协商 给浏览器一个文件

# file in a language the user can understand.   用一种用户可以理解的语言

#

# Specify a default language. This means that all data     指定一种默认的语言,这意味着所有没有指定语言的包都将使用该语言

# going out without a specific language tag (see below) will

# be marked with this one. You probably do NOT want to set   你可能不想设置这个,除非你确信这样做是正确的

# this unless you are sure it is correct for all cases.

#

# * It is generally better to not mark a page as     通常,不使用确定的某一语言比使用错误的语言要好

# * being a certain language than marking it with the wrong

# * language!

#

# DefaultLanguage nl

#

# Note 1: The suffix does not have to be the same as the language  注意1:语言关键词的后缀是不能一样的

# keyword --- those with documents in Polish (whose net-standard   波兰语的文档(网络标准语言代码是pl)希望使用AddLanguage pl .po

# language code is pl) may wish to use "AddLanguage pl .po" to   来避免与perl脚本的通用后缀产生歧义

# avoid the ambiguity with the common suffix for perl scripts.

#

# Note 2: The example entries below illustrate that in some cases   注意2: 下面的例子举例说明在一些情况下 语言的二字符缩写 它的国家

# the two character 'Language' abbreviation is not identical to    的二字符缩写不相同

# the two character 'Country' code for its country,

# E.g. 'Danmark/dk' versus 'Danish/da'.                 例如   丹麦二字符缩写为dk   对应的  丹麦语二字符缩写为da

#

# Note 3: In the case of 'ltz' we violate the RFC by using a three char   注意3: 在 “ltz” 的情况下我们使用三字符词缀,违犯了 RFC的规定

# specifier. There is 'work in progress' to fix this and get   在运行中会修复它

# the reference data for rfc1766 cleaned up.     并使用RFC1766标准整理取得参考数据

#

# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)

# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)

# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)

# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)

# Norwegian (no) - Polish (pl) - Portugese (pt)

# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)

Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)     简体     繁体

#

AddLanguage ca .ca

AddLanguage cs .cz .cs

AddLanguage da .dk

AddLanguage de .de

AddLanguage el .el

AddLanguage en .en

AddLanguage eo .eo

AddLanguage es .es

AddLanguage et .et

AddLanguage fr .fr

AddLanguage he .he

AddLanguage hr .hr

AddLanguage it .it

AddLanguage ja .ja

AddLanguage ko .ko

AddLanguage ltz .ltz

AddLanguage nl .nl

AddLanguage nn .nn

AddLanguage no .no

AddLanguage pl .po

AddLanguage pt .pt

AddLanguage pt-BR .pt-br

AddLanguage ru .ru

AddLanguage sv .sv

AddLanguage zh-CN .zh-cn

AddLanguage zh-TW .zh-tw

#

# LanguagePriority allows you to give precedence to some languages   语言优先级:允许你给予一些语言优先级

# in case of a tie during content negotiation.   在内容协商 级别相同的情况下

#

# Just list the languages in decreasing order of preference. We have    以优先次序递减的方式列出它们

# more or less alphabetized them here. You probably want to change this.  我们或多或少的依照字母顺序排列,你可能会想改变这些

#

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW

#                        (强制语言优先级)

# ForceLanguagePriority allows you to serve a result page rather than  强制语言优先级:允许你提供一个结果页取代了

# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)  多项选择(Prefer) [级别相同时] 或者不接受(Fallback)

# [in case no accepted languages matched the available variants]   [没有可接受的语言匹配的情况]

#

ForceLanguagePriority Prefer Fallback
                                       Prefer     当有多种语言可以匹配时 使用LanguagePriority 列表第一项
                                       Fallback  当没有语言可以匹配时 使用LanguagePriority 列表第一项

#

# Specify a default charset for all content served; this enables  指定默认的字符集为所有的服务内容

# interpretation of all content as UTF-8 by default.  To use the    这将所有内容默认以utf-8编码解析。 要使用浏览器默认选择

# default browser choice (ISO-8859-1), or to allow the META tags   (ISO-8859-1)或允许使用HTML的META来自动选择浏览器编码

# in HTML content to override this choice, comment out this   注释掉这行即可

# directive:

#

AddDefaultCharset UTF-8                     指定默认字符集

#

# AddType allows you to add to or override the MIME configuration   AddType 允许你添加覆盖MIME配置文件 mime.types

# file mime.types for specific file types.      为专门指定的文件类型

#

#AddType application/x-tar .tgz       去掉注释 则表示允许某些浏览器在线解压指定类型文件

AddType  指明文件的MIME类型(内容类型)
AddType 是与类型表相关的,描述的是扩展名与文件类型之间的关系
AddType application/x-tar .tgz        
说明   .tgz扩展名的文件就是 application/x-tar 类型的; 
在内容协商时,如果客户端需要是application/x-tar 类型的,就将 .tgz结尾的资源返回

#                   AddEncoding  指明文档的编码方式(在文件扩展名与特定的编码方式间建立映射关系)

# AddEncoding allows you to have certain browsers uncompress    AddEncoding:允许浏览器在线解压

# information on the fly. Note: Not all browsers support this.   非所有的浏览器都支持这个

# Despite the name similarity, the following Add* directives have nothing   尽管名字相似,但下方的Add指令

# to do with the FancyIndexing customization directives above.  与上面的FancyIndexing定制指令不同

#

#AddEncoding x-compress .Z

#AddEncoding x-gzip .gz .tgz

# If the AddEncoding directives above are commented-out, then you  如果上面的AddEncoding指令被注释了

# probably should define those extensions to indicate media types:  你应该定义这些扩展指出其类型

#

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

 

#

#   MIME-types for downloading Certificates and CRLs   下载证书及crls算法 所使用的映射类型

#

AddType application/x-x509-ca-cert .crt

AddType application/x-pkcs7-crl    .crl

 

#

# AddHandler allows you to map certain file extensions to "handlers":   AddHandler:允许你映射确定的文件扩展名到“handlers”

# actions unrelated to filetype. These can be either built into the server    与文件类型无关的行为。这既能编译到服务器中

# or added with the Action directive (see below)  也可以添加到Action指令中(看下面)

#

# To use CGI scripts outside of ScriptAliased directories:   为了在ScriptAliased指令以外使用CGI脚本

# (You will also need to add "ExecCGI" to the "Options" directive.) (要使它可用,你还需要在Options中添加“ExecCGI”)

#

#AddHandler cgi-script .cgi   AddHandler 说明什么样的扩展名使用什么样的程序来处理,描述的是扩展名与处理程序之间的关系

 

#

# For files that include their own HTTP headers:    对于那些包含他们自己的HTTP头的文件

#

#AddHandler send-as-is asis

#

# For type maps (negotiated resources):       对于类型映像:(转移资源)

# (This is enabled by default to allow the Apache "It Worked" page   (这是默认的设定以允许Apache的“It Worked”页能多种语言分发)

#  to be distributed in multiple languages.)

#

AddHandler type-map var                      允许关于显示主页时进行内容协商,根据不同语言来显示相应主页

#

# Filters allow you to process content before it is sent to the client.   过滤器 允许你在将内容发送到客户端前进行处理

#

# To parse .shtml files for server-side includes (SSI):    为了在服务器端分析包含(SSI)的.shtml文档

# (You will also need to add "Includes" to the "Options" directive.)  (要执行这个指令,你还需要在Options指令中添加“Includes”。)

#

AddType text/html .shtml                              定义SSI文件的扩展名

AddOutputFilter INCLUDES .shtml                增加处理.shtml文件的方法

 

#

# Action lets you define media types that will execute a script whenever  Action让你定义当调用匹配的媒体文件时将要执行的脚本

# a matching file is called. This eliminates the need for repeated URL  这将减少那些经常使用的CGI脚本的URL路径名的重复输入

# pathnames for oft-used CGI file processors.

# Format: Action media/type /cgi-script/location     格式:Action media/type /cgi-script/location

# Format: Action handler-name /cgi-script/location    格式: Action handler-name /cgi-script/location

#

#

# Customizable error responses come in three flavors:    可配置的错误应答有三种风格

# 1) plain text 2) local redirects 3) external redirects  1.纯文本 2.本地重定向  3.外部重定向

#

# Some examples:   一些例子

#ErrorDocument 500 "The server made a boo boo."

#ErrorDocument 404 /missing.html

#ErrorDocument 404 "/cgi-bin/missing_handler.pl"

#ErrorDocument 402 http://www.example.com/subscription_info.html

#

#

# Putting this all together, we can internationalize error responses.  把这些放在一起,我们可以做国际化的错误应答

#

# We use Alias to redirect any /error/HTTP_<error>.html.var response to  我们使用Alias来重定向任意/error/HTTP_<error>.html.var应答

# our collection of by-error message multi-language collections.  We use   我们收集的多种语言集合的错误信息

# includes to substitute the appropriate text.            使用正确的文本替代它

#

# You can modify the messages' appearance without changing any of the   通过加入下面的行,你就能够改变这些消息的显示,而不必改变

# default HTTP_<error>.html.var files by adding the line:    默认的HTTP_<error>.html.var文件

#

#   Alias /error/include/ "/your/include/path/"

#

# which allows you to create your own set of files by starting with the    可以开始 允许你创建你自己的文件

# /var/www/error/include/ files and   将/var/www/error/include/ 下的文件拷贝到/your/include/path/下

# copying them to /your/include/path/, even on a per-VirtualHost basis.     甚至是其于每个虚拟主机的

#

Alias /error/ "/var/www/error/"              定义出错信息别名目录

 

<IfModule mod_negotiation.c>

<IfModule mod_include.c>

    <Directory "/var/www/error">

        AllowOverride None

        Options IncludesNoExec

        AddOutputFilter Includes html

        AddHandler type-map var

        Order allow,deny

        Allow from all

        LanguagePriority en es de fr

        ForceLanguagePriority Prefer Fallback

    </Directory>

#    ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var                  定义错误编号和文档的对应关系

#    ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var

#    ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var

#    ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var

#    ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var

#    ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var

#    ErrorDocument 410 /error/HTTP_GONE.html.var

#    ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var

#    ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var

#    ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var

#    ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var

#    ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var

#    ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var

#    ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var

#    ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var

#    ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var

#    ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var

</IfModule>

</IfModule>

#

# The following directives modify normal HTTP response behavior to  下面的命令更改标准的HTTP应答行为以处理己知的浏览器问题

# handle known problems with browser implementations.

#

BrowserMatch "Mozilla/2" nokeepalive                                         定义与浏览器匹配的类型所对应的特性

BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

BrowserMatch "RealPlayer 4\.0" force-response-1.0

BrowserMatch "Java/1\.0" force-response-1.0

BrowserMatch "JDK/1\.0" force-response-1.0

#

# The following directive disables redirects on non-GET requests for     下面命令关闭对那些没有尾部“/”的目录的非GET请求的重定向

# a directory that does not include the trailing slash.  This fixes a   这些命令修复了微软的采用DAV方法

# problem with Microsoft WebFolders which does not appropriately handle  不能正确处理重定向的WEB文件夹的问题

# redirects for folders with DAV methods.   Apple下的DAV文件系统和

# Same deal with Apple's DAV filesystem and Gnome VFS support for DAV.    Gnome下的VFS对DAV的支持也是采用这样的方法

#

BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully

BrowserMatch "MS FrontPage" redirect-carefully

BrowserMatch "^WebDrive" redirect-carefully

BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully

BrowserMatch "^gnome-vfs/1.0" redirect-carefully

BrowserMatch "^XML Spy" redirect-carefully

BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully

#

# Allow server status reports generated by mod_status,    允许服务器生成报告通过 mod_status扩展

# with the URL of   http://servername/server-status              在这个网页地址

# Change the ".example.com" to match your domain to enable.    改变.example.com为你自己的域名

#

#<Location /server-status>                                             定义服务器状态

#    SetHandler server-status                                            可以报告详细的服务器状态

#    Order deny,allow                                                           此段配置与ExtendedStatus On 相关 一般二者同时起作用

#    Deny from all

#    Allow from .example.com

#</Location>

#

# Allow remote server configuration reports, with the URL of   允许通过http://servername/server-info 网页远程报告服务器配置信息

#  http://servername/server-info (requires that mod_info.c be loaded).  需要加载mod_info.c模块

# Change the ".example.com" to match your domain to enable.    改变“.example.com”为你自己的域名

#

#<Location /server-info>

#    SetHandler server-info

#    Order deny,allow

#    Deny from all

#    Allow from .example.com

#</Location>

 

#

# Proxy Server directives. Uncomment the following lines to   代理服务器命令,去掉下面的注释使代理服务可用

# enable the proxy server:

#

#<IfModule mod_proxy.c>

#ProxyRequests On

#

#<Proxy *>

#    Order deny,allow

#    Deny from all

#    Allow from .example.com

#</Proxy>

 

#

# Enable/disable the handling of HTTP/1.1 "Via:" headers.

# ("Full" adds the server version; "Block" removes all outgoing Via: headers)

# Set to one of: Off | On | Full | Block

#

#ProxyVia On

 

#

# To enable a cache of proxied content, uncomment the following lines.

# See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details.

#

#<IfModule mod_disk_cache.c>

#   CacheEnable disk /

#   CacheRoot "/var/cache/mod_proxy"

#</IfModule>

#

 

#</IfModule>

# End of proxy directives.   代理指令结束

日志超过规定字数 下一篇继续写

Apache httpd.conf配置文件 2

http://centos2014.blog.163.com/blog/static/2405420442014111810447532/