当前位置: 移动技术网 > 网络运营>服务器>Linux > Apache服务器主配置文件httpd.conf详解

Apache服务器主配置文件httpd.conf详解

2019年05月01日  | 移动技术网网络运营  | 我要评论

apache 2.2

# 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.2/> for detailed information.
# in particular, see
# <url:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive. 
 
 
# 这是主apache服务器配置文件。
# 它给服务器指示配置指令。
# 可去http://httpd.apache.org/docs/2.2/查看详细信息
# 特别情况可去http://httpd.apache.org/docs/2.2/mod/directives.html
# 对每个配置指示进行讨论 
 
 
 
 
# 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').
# 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.
# 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. 
 
 
 
 
# 要明白这些指令是做什么的。这里只是一点提醒信息。
# 
# 配置指示分为三个基本组:# 1. 全局控制apache操作指示。# 2. 'main'或者'default'服务器参数定义,#  这些参数响应非虚拟主机的操作请求。同时也为所以虚拟主机提供了默认设定值。# 3. 设置虚拟主机,可以通过一个apache服务器来实现处理不同ip或者主机名的web请求。 
 
 
 
 
 
 
# 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 "/etc/httpd" will be interpreted by the
# server as "/etc/httpd/logs/foo.log". 
 
 
# 配置名和日志文件名:# 如果用“/”或者win32的“drive:/”开头,来指定服务器的控制文件名,服务器将使用显式路径。# 如果未用“/”开头,比如文件名“logs/foo.log”,假设服务器根目录为“/etc/httpd”,# 则,服务器会将它解释为“/etc/httpd/logs/foo.log”。 
 
 
### 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. 
### 章节1:全局环境# 这节的指令影响apache的整体操作,比如它能操作的当前连接请求数目或者去哪里# 查找其配置文件等。 
 
 
# don't give away too much information about all the subcomponents
# we are running. comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
servertokens os 
# 不要泄漏太多的服务器信息。# 如果不想让远程站点了解到你的主要选型模块信息,可以注释掉该行。 
 
 
 
 
# serverroot: the top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# 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.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# do not add a slash at the end of the directory path.
#
serverroot "/etc/httpd" 
 
 
 
 
# 服务器的根:目录树的顶部,其下存放着配置、错误,以及日志文件等。## 注意!如果你打算将它放到挂载文件系统的nfs(或者其他网络),建议参阅lockfile文档# (有效链接为http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile)# 你将省去不少麻烦。# # 不要在目录的末尾加斜线“/”# serverroot "/etc/httpd" 
 
 
 
 
# pidfile: the file in which the server should record its process
# identification number when it starts.
#
pidfile run/httpd.pid 
# pid文件:当进程启动时,服务器应当在其中记录pid。# pidfile run/httpd.pid 
 
 
#
# timeout: the number of seconds before receives and sends time out.
#
timeout 120 
# timeout:确定发送超时和接收超时的秒数。timeout 120 
 
 
#
# keepalive: whether or not to allow persistent connections (more than
# one request per connection). set to "off" to deactivate.
#
keepalive off 
# keepalive:是否允许保持连接状态(每次连接可以执行多个请求)。一般设置为“off”。keepalive off 
 
 
 
 
#
# 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 100 
 
 
# maxkeepaliverequests:持续连接最大数。0表示无限数量。# 为了最大性能,推荐将其设置高一点。maxkeepaliverequests 100 
 
 
#
# keepalivetimeout: number of seconds to wait for the next request from the
# same client on the same connection.
#
keepalivetimeout 15 
# keepalivetimeout:同一客户端同一连接请求的间隔秒数。keepalivetimeout 15 
 
 
##
## server-pool size regulation (mpm specific)
## 
## 服务器池大小调整(mpm 特性) 
 
 
 
 
# prefork mpm
# startservers: number of server processes to start
# minspareservers: minimum number of server processes which are kept spare
# maxspareservers: maximum number of server processes which are kept spare
# serverlimit: maximum value for maxclients for the lifetime of the server
# maxclients: maximum number of server processes allowed to start
# maxrequestsperchild: maximum number of requests a server process serves
<ifmodule prefork.c>
startservers    8
minspareservers  5
maxspareservers  20
serverlimit   256
maxclients    256
maxrequestsperchild 4000
</ifmodule> 
 
 
 
 
# prefork mpm(预分离多进程模块)# startservices:服务器启动进程数# minspareservers:最小空闲进程数# maxspareservers:最大空闲进程数# serverlimit:最大进程数maxclients时,服务器的最大生存时间值# maxclients:服务器运行启动的最大进程数量# maxrequestperchild:每个服务子进程的最大请求数量<ifmodule prefork.c>startservers    8minspareservers  5maxspareservers  20serverlimit   256maxclients    256maxrequestsperchild 4000</ifmodule> 
 
 
 
 
 
 
# worker mpm
# startservers: initial number of server processes to start
# maxclients: maximum number of simultaneous client connections
# minsparethreads: minimum number of worker threads which are kept spare
# maxsparethreads: maximum number of worker threads which are kept spare
# threadsperchild: constant number of worker threads in each server process
# maxrequestsperchild: maximum number of requests a server process serves
<ifmodule worker.c>
startservers     2
maxclients     150
minsparethreads   25
maxsparethreads   75
threadsperchild   25
maxrequestsperchild 0
</ifmodule> 
 
 
 
 
# worker 多进程模块# startservers:服务器启动进程的初始化数目# maxclients:同时客户端连接的最大数目# minsparethreads:最小空闲worker线程数# maxsparethreads:最大空闲worker线程数# threadsperchild:每个服务器子进程的worker线程数# maxrequestsperchild:每个子进程的最大请求数<ifmodule worker.c>startservers     2maxclients     150minsparethreads   25maxsparethreads   75threadsperchild   25maxrequestsperchild 0</ifmodule> 
 
 
 
 
 
 
#
# listen: allows you to bind apache to specific ip addresses and/or
# ports, in addition to the default. see also the <virtualhost>
# directive.
#
# 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)
#
#listen 12.34.56.78:80
listen 80 
 
 
 
 
# listen:允许将apache绑定到除了默认值之外的特定的ip地址和/或端口。也可# 查看<virtualhost>指令。# # 如下设置特定ip地址,可防止apache接收所有绑定的ip(0.0.0.0)# 默认接收所有ip,特定ip的listen被“#”注释掉#listen 12.34.56.78:80listen 80 
 
 
 
 
 
 
#
# dynamic shared object (dso) support
#
# 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.
#
# example:
# loadmodule foo_module modules/mod_foo.so
# 
 
 
 
 
# # 动态共享对象(dso)支持# # 为了能使用编译为dso的模块函数,我们必须将相应的‘loadmodule'行放在此处,这样模块中的指令将有效。# 静态编译模块(用‘httpd -l'命令可以列出)不需要在这里加载。# # 示例:# loadmodule foo_module modules/mod_foo.so# 
 
 
 
 
loadmodule auth_basic_module modules/mod_auth_basic.so
loadmodule auth_digest_module modules/mod_auth_digest.so
loadmodule authn_file_module modules/mod_authn_file.so
loadmodule authn_alias_module modules/mod_authn_alias.so
loadmodule authn_anon_module modules/mod_authn_anon.so
loadmodule authn_dbm_module modules/mod_authn_dbm.so
loadmodule authn_default_module modules/mod_authn_default.so
loadmodule authz_host_module modules/mod_authz_host.so
loadmodule authz_user_module modules/mod_authz_user.so
loadmodule authz_owner_module modules/mod_authz_owner.so
loadmodule authz_groupfile_module modules/mod_authz_groupfile.so
loadmodule authz_dbm_module modules/mod_authz_dbm.so
loadmodule authz_default_module modules/mod_authz_default.so
loadmodule ldap_module modules/mod_ldap.so
loadmodule authnz_ldap_module modules/mod_authnz_ldap.so
loadmodule include_module modules/mod_include.so
loadmodule log_config_module modules/mod_log_config.so
loadmodule logio_module modules/mod_logio.so
loadmodule env_module modules/mod_env.so
loadmodule ext_filter_module modules/mod_ext_filter.so
loadmodule mime_magic_module modules/mod_mime_magic.so
loadmodule expires_module modules/mod_expires.so
loadmodule deflate_module modules/mod_deflate.so
loadmodule headers_module modules/mod_headers.so
loadmodule usertrack_module modules/mod_usertrack.so
loadmodule setenvif_module modules/mod_setenvif.so
loadmodule mime_module modules/mod_mime.so
loadmodule dav_module modules/mod_dav.so
loadmodule status_module modules/mod_status.so
loadmodule autoindex_module modules/mod_autoindex.so
loadmodule info_module modules/mod_info.so
loadmodule dav_fs_module modules/mod_dav_fs.so
loadmodule vhost_alias_module modules/mod_vhost_alias.so
loadmodule negotiation_module modules/mod_negotiation.so
loadmodule dir_module modules/mod_dir.so
loadmodule actions_module modules/mod_actions.so
loadmodule speling_module modules/mod_speling.soloadmodule userdir_module modules/mod_userdir.soloadmodule alias_module modules/mod_alias.soloadmodule rewrite_module modules/mod_rewrite.soloadmodule proxy_module modules/mod_proxy.soloadmodule proxy_balancer_module modules/mod_proxy_balancer.soloadmodule proxy_ftp_module modules/mod_proxy_ftp.soloadmodule proxy_http_module modules/mod_proxy_http.soloadmodule proxy_connect_module modules/mod_proxy_connect.soloadmodule cache_module modules/mod_cache.soloadmodule suexec_module modules/mod_suexec.soloadmodule disk_cache_module modules/mod_disk_cache.soloadmodule file_cache_module modules/mod_file_cache.soloadmodule mem_cache_module modules/mod_mem_cache.soloadmodule cgi_module modules/mod_cgi.soloadmodule version_module modules/mod_version.so## the following modules are not loaded by default:##loadmodule cern_meta_module modules/mod_cern_meta.so#loadmodule asis_module modules/mod_asis.so 
 
 
 
 
#
# load config files from the config directory "/etc/httpd/conf.d".
#
include conf.d/*.conf 
# 从config目录“/etc/httpd/conf.d”加载配置文件# *.conf兼容老版本的apacheinclude conf.d/*.conf 
 
 
 
 
#
# 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.
#
#extendedstatus on 
 
 
# extendedstatus 在“server-status”操作被调用时,控制apache是否产生“full”状态信息(on)或者# 基本信息(off)。默认为off。##extendedstatus on 
 
 
 
 
#
# if you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# user/group: the name (or #number) of the user/group to run httpd as.
# . on sco (odt 3) use "user nouser" and "group nogroup".
# . on hpux you may not be able to use shared memory as nobody, and the
#  suggested workaround is to create a user www and use that user.
# note that some kernels refuse to setgid(group) or semctl(ipc_set)
# when the value of (unsigned)group is above 60000;
# don't use group #-1 on these systems!
#
user apache
group apache 
 
 
 
 
# 如果想要httpd作为一个不同用户或组来运行,最初就必须以root来运行httpd,它会切换到其他用户或组去。# # 用户/组:作为运行httpd的用户/组的名称。# - 在sco(odt 3)上,使用“user nouser”和“group nogroup”。# - 在hpux上,将无法使用共享存储作为nobody,建议的解决办法是创建一个用户www并使用这个用户。# 注意,有的内核不支持60000以上的组id值,在这些系统中不要使用“group #-1”。# user apachegroup apache 
 
 
 
 
 
 
### 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.
#
# all of these directives may appear inside <virtualhost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
# 
 
 
 
 
### 章节2:‘main'服务器配置# # 该章节设置‘main'服务器使用的指令,响应所有非<virtualhost>定义的请求。# 这些指令值也为<virtualhost>部分提供默认值。# # 所有这些指令都可以在<virtualhost>段中出现,此时,这些默认值将被虚拟主机的相关设置值所覆盖。 
 
 
 
 
 
 
#
# 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. admin@your-domain.com
#
serveradmin root@localhost 
 
 
# serveradmin:服务器管理员的邮箱地址,该地址一般出现在服务器生成页中,比如错误文档等。serveradmin root@localhost 
 
 
 
 
#
# 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.
#
# if this is not set to valid dns name for your host, server-generated
# redirections will not work. see also the usecanonicalname directive.
#
# 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.
#
#servername www.example.com:80 
 
 
 
 
# servername 给出一个服务器用来标识它自己的名称和端口。# 通常被自动指定,但为避免启动时的问题,推荐明确指定它。# # 如果主机没有设置有效的dns名称,server-generated指令将不会工作。# # 如果主机没有注册dns,输入其ip地址。这样就可以通过ip地址访问你的主机了。# #servername www.example.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 off 
 
 
# usecanonicalname:确定apache如何构建自引用urls和server_name、server_port变量。# 当设为off时,apache将使用客户端支持的hostname和port。当设为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 "/var/www/html" 
 
 
# documentroot:提供文档的根目录。# 默认,所有请求都由该目录提供,但是可以用连接符和别名指向其他位置。# documentroot “/var/www/html” 
 
 
 
 
#
# 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).
#
# first, we configure the "default" to be a very restrictive set of
# features.
#
<directory />
  options followsymlinks
  allowoverride none
</directory> 
 
 
 
 
# 每个apache存取的目录(包括子目录)都可配置为允许和禁止。# # 首先,我们配置严格特征集合的默认值。# <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.
#
<directory "/var/www/html"> 
# 这里应当根据你设定的documentroot值进行修改。<directory “/var/www/html”> 
 
 
 
 
#
# possible values for the options directive are "none", "all",
# or any combination of:
#  indexes includes followsymlinks symlinksifownermatch execcgi multiviews
#
# note that "multiviews" must be named *explicitly* --- "options all"
# doesn't give it to you.
#
# 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 
 
 
 
 
# 指令选项值可以是“none”、“all”,或者下面的任何组合:#   indexes includes followsymlinks symlinksifownermatch execcgi multiviews# # 注意,“multiviews”必须被清楚地指定---“all”不会帮你指定。# # 指令选项复杂并且重要。详细信息请查阅http://httpd.apache.org/docs/2.2/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 none 
 
 
# allowoverride 允许优先,用来控制哪些指令可以放到.htaccess文件中。# 可以是“all”、“none”,或者下面关键字的任何组合:#   options fileinfo authconfig limit#   allowoverride none 
 
 
 
 
#
# controls who can get stuff from this server.
#
  order allow,deny
  allow from all
 
</directory> 
 
 
# 控制谁可能获得服务器阻塞  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.
#
# the path to the end user account 'public_html' directory must be
# accessible to the webserver userid. this usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# otherwise, the client will only receive a "403 forbidden" message.
#
# 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 disable
 
  #
  # to enable requests to /~user/ to serve the user's public_html
  # directory, remove the "userdir disable" line above, and uncomment
  # the following line instead:
  #
  #userdir public_html
 
</ifmodule> 
 
 
 
 
# userdir:当接收到~user请求时,附加到用户home目录上的目录名称。# # 端用户账户路径‘public_html'路径对web服务器用户id必须是可存取的。# 这通常意味着~userid必须拥有711权限值,~userid/public_html必须有755权限值,# 并且其中包含的文件都是公开的。否则,客户端只能收到“403 forbidden”消息。# # 可查阅:http://httpd.apache.org/docs/misc/faq.html#forbidden# <ifmodule mod_userdir.c>  # userdir默认被禁止掉,这样可以确定一个系统用户名的存在(依赖home路径许可)。  userdir disable    # 要使能/~user/请求以提供用户的public_html目录的话,删除上面的“userdir disable”行,  # 并且取消下面的注释:  #userdir public_html</ifmodule> 
 
 
 
 
 
 
#
# 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
#  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> 
 
 
 
 
# userdir目录的存取控制。以下是一个这些目录被限制到只读的站点示例。# #<directory /home/*/public_html>#  allowoverride fileinfo authconfig limit#  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
# is requested.
#
# the .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.
#
directoryindex  .var 
 
 
# directoryindex:如果一个目录被请求时,设置apache将提供文件的目录索引。# # .var文件用来传递内容协商了的文档。multiviews选项可用于相同目的,但是太慢了。# directoryindex  .var 
 
 
 
 
#
# accessfilename: the name of the file to look for in each directory
# for additional configuration directives. see also the allowoverride
# directive.
#
accessfilename .htaccess 
 
 
# accessfilename:附加存取指令的文件的名称。也可参照allowoverride指令。accessfilename .htaccess 
 
 
 
 
#
# the following lines prevent .htaccess and .htpasswd files from being
# viewed by web clients.
#
<files ~ "^\.ht">
  order allow,deny
  deny from all
</files> 
 
 
# 下面的行防止.htaccess和.htpasswd文件被web客户端查看。<files ~ "^\.ht">  order allow,deny  deny from all</files> 
 
 
#
# typesconfig describes where the mime.types file (or equivalent) is
# to be found.
#
typesconfig /etc/mime.types 
# typesconfig 描述了mime.types文件在哪typesconfig /etc/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.
# 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.
#
defaulttype text/plain 
 
 
# defaulttype 是服务器无法从文件扩展名确定文档类型时,将使用的默认mime类型。# 如果你的服务器大部分都是text和html文档,“text/plain”是一个合适值。# 如果你的服务器大部分都是二进制文档,“application/octet-stream”可避免服务器尝试用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.
#
<ifmodule mod_mime_magic.c>
#  mimemagicfile /usr/share/magic.mime
  mimemagicfile conf/magic
</ifmodule> 
 
 
 
 
# mod_mime_magic模块允许服务器从文件内容来确定文件类型。# mimemagicfile指令告诉该模块隐含文件类型信息的位置。<ifmodule mod_mime_magic.c>#  mimemagicfile /usr/share/magic.mime  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 off 
 
 
# hostnamelookups:将客户端名称或其ip地址加入日志。# 默认为off对整个网络比较好,如果有人明知却非要打开这个特性,那么使能它意味着每个客户端请求都将# 导致至少一个域名服务器查询请求。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.2/mod/core.html#enablemmap
#
#enablemmap off 
 
 
 
 
# enablemmap:存储器镜像文件传输控制(需要操作系统的支持)。# 默认为on;如果从nfs-mounted文件系统提供文件则设为off。# 有些系统,设为off(不考虑文件系统)能提高性能;详情请# 查阅http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap# #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.2/mod/core.html#enablesendfile
#
#enablesendfile off 
 
 
# enablesendfile:文件传输内核使能控制(需要系统支持)。# 默认为on;如果从nfs-mounted文件系统提供文件则设为off。# 请查阅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>
# 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 
 
 
# errorlog:错误日志文件的位置。# 如果不在<virtualhost>段中指定错误日志指令,虚拟主机的错误日志信息也会记录到这个文件。# 如果在<virtualhost>段中指定错误日志指令,则此虚拟主机的错误将会在那里记录而不在该文件记录。# 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.
#
loglevel warn 
 
 
# loglevel:控制什么级别的信息被记录到error_log日志文件中。# 可能的值包括: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).
#
logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combine
d
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
# requires the mod_logio module to be loaded.
#logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\" %i %o" combinedio 
 
 
# 下面的指令,为customlog指令定义了一些昵称。# “combinedio”包含实际接收和发送字节的实际计数;这需要加载mod_logio模块。 
 
 
 
 
#
# the location and format of the access logfile (common logfile format).
# if you do not define any access logfiles within a <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 
 
 
# 普通日志文件的位置和格式。# 若在<virtualhost>段中定义该指令,则其普通日志文件不会存在该文件中。# #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 
 
 
# 若是想分离代理和引用日志文件,则取消下面指令的注释。# #customlog logs/referer_log referer#customlog logs/agent_log agent 
 
 
#
# for a single logfile with access, agent, and referer information
# (combined logfile format), use the following directive:
#
customlog logs/access_log combined 
# 若是不想用分离代理和引用日志文件,则用下面的指令:# 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
# listings, mod_status and mod_info output etc., but not cgi generated
# documents or custom error documents).
# set to "email" to also include a mailto: link to the serveradmin.
# set to one of: on | off | email
#
serversignature on 
 
 
 
 
# 可选地添加一行包含服务器版本和虚拟主机名称信息到服务器生成的页中(内部错误文档、ftp目录列表、mod_status和# mod_info输出等,但非cgi生成文档或者自定义错误文档)。# 设置为“email”也包含mailto管理员邮箱的链接。# 可设置为其中之一: on | off | email# serversignature on 
 
 
 
 
 
 
#
# aliases: add here as many aliases as you need (with no limit). the format is
# alias fakename realname
#
# note that if you include a trailing / on fakename then the server will
# require it to be present in the url. so "/icons" isn't aliased in this
# 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
# do not use fancyindexing, you may comment this out.
#
alias /icons/ "/var/www/icons/"
 
<directory "/var/www/icons">
  options indexes multiviews
  allowoverride none
  order allow,deny
  allow from all
</directory> 
 
 
# aliases:在此添加无限个你需要的别名。# 格式为 alias 别名 真名# 注意,如果别名中以“/”结尾,则服务器将要求“/”出现在url中。# 别名中有“/”,则真名中必须有“/”。反之亦然。# 
 
 
 
 
#
# webdav module configuration section.
#
<ifmodule mod_dav_fs.c>
  # location of the webdav lock database.
  davlockdb /var/lib/dav/lockdb
</ifmodule> 
 
 
# webdav模块配置部分。# webdav锁定数据库的位置设置。 
 
 
 
 
#
# scriptalias: this controls which directories contain server scripts.
# scriptaliases are essentially the same as aliases, except that
# 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/" 
 
 
# scriptalias:服务器脚本目录别名。# 脚本目录存放服务器响应请求时执行的应用程序,而非发送给客户端的文件。# “/”的处理跟alias相同。# scriptalias /cgi-bin/ “/var/www/cgi-bin/” 
 
 
 
 
#
# "/var/www/cgi-bin" should be changed to whatever your scriptaliased
# cgi directory exists, if you have that configured.
#
<directory "/var/www/cgi-bin">
  allowoverride none
  options none
  order allow,deny
  allow from all
</directory> 
 
 
# “/var/www/cgi-bin”应当对应到你自己的cgi路径,如果你需要该配置。 
 
 
 
 
#
# redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. this allows you to tell the
# clients where to look for the relocated document.
# example:
# redirect permanent /foo http://www.example.com/bar 
 
 
# 重定向允许你告诉客户端曾经在你空间中使用的文档已经不存在了。通知客户端去什么位置查找文档。 
 
 
#
# directives controlling the display of server-generated directory listings.
# 
#
# 服务器生成路径列表显示的控制指令# 
 
 
#
# indexoptions: controls the appearance of server-generated directory
# listings.
#
indexoptions fancyindexing versionsort namewidth=* htmltable 
# indexoptions:服务器生成目录列表的索引控制。indexoptions fancyindexing versionsort namewidth=* htmltable 
 
 
 
 
#
# addicon* directives tell the server which icon to show for different
# files or filename extensions. these are only displayed for
# 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* 指令使服务器对不同文件显示不同的文件类型图标。 
 
 
#
# defaulticon is which icon to show for files which do not have an icon
# explicitly set.
#
defaulticon /icons/unknown.gif 
# defaulticon为未明确设置图标的文件指定一个默认类型图标。defaulticon /icons/unknown.gif 
 
 
 
 
#
# adddescription allows you to place a short description after a file in
# server-generated indexes. these are only displayed for fancyindexed
# directories.
# format: adddescription "description" filename
#
#adddescription "gzip compressed document" .gz
#adddescription "tar archive" .tar
#adddescription "gzip compressed tar archive" .tgz 
 
 
# 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
# default, and append to directory listings.
#
# headername is the name of a file which should be prepended to
# directory indexes.
readmename readme.html
headername header.html 
 
 
# readmename 是附加到目录列表的readme文件(服务器将默认查找)的名称指定命令。# headername 是应当添加到目录索引中的文件名称。readmename readme.html
headername header.html 
 
 
#
# indexignore is a set of filenames which directory indexing should ignore
# and not include in the listing. shell-style wildcarding is permitted.
#
indexignore .??* *~ *# header* readme* rcs cvs *,v *,t 
# indexignore索引忽略,即目录索引应当忽略并且不包括在列表里的文件集。允许shell风格的通配符。indexignore .??* *~ *# header* readme* rcs cvs *,v *,t

老版本

#
# apache服务器主配置文件. 包括服务器指令的目录设置.
# 详见 <url:http://www.apache.org/docs/>
#
# 请在理解用途的基础上阅读各指令。
#
# 再读取此文档后,服务器将继续搜索运行
# e:/program files/apache group/apache/conf/srm.conf
# e:/program files/apache group/apache/conf/access.conf
# 除非用resourceconfig或accessconfig覆盖这儿的标识
#
# 配置标识由三个基本部分组成:
# 1. 作为一个整体来控制apache服务器进程的标识 (the 'global environment').
# 2. 用于定义主(默认)服务器参数的标识。
# 响应虚拟主机不能处理的请求。
# 同时也提供所有虚拟主机的设置值。
# 3. 虚拟主机的设置。在一个apache服务器进程中配置不同的ip地址和主机名。
#
# 配置和日志文件名:指定服务器控制文件命名时,
# 以 "/" (或 "drive:/" for win32)开始,服务器将使用这些绝对路径。
# 如果文件名不是以"/"开始的,预先考虑服务器根目录--
# 因此 "logs/foo.log",如果服务器根目录是"/usr/local/apache",
# 服务器将解释为 "/usr/local/apache/logs/foo.log".
#
# 注: 指定的文件名需要用"/"代替"\"。
# (例, "c:/apache" 代替 "c:\apache").
# 如果省略了驱动器名,默认使用apache.exe所在的驱动器盘符
# 建议指定盘符,以免混乱。
#

### 部分 1: 全局环境
#
# 本部分的表示将影响所有apache的操作
# 例如,所能处理的并发请求数或配置文件地址
#

#
# servertype 可取值 inetd 或 standalone. inetd 只适用于unix平台
#
servertype standalone

#
# serverroot: 目录树的根结点。服务器配置、出错信息、日志文件都保存在根目录下。
#
# 不要再目录末尾加"/"
#
serverroot "c:/program files/apache group/apache"

#
# pidfile: 服务器用于记录启动时进程id的文件。
#
pidfile logs/httpd.pid

#
# scoreboardfile: 用于保存内部服务器进程信息的文件。
# 并非必须。 但是如果指定了(此文件当运行apache时生成)
# 那么必须确保没有两个apache进程共享同一个scoreboard文件。
#
scoreboardfile logs/apache_runtime_status

#
# 在标准配置下,服务器将顺序读取 httpd.conf(此文件可通过命令行中-f参数指定),
# srm.conf 和 access.conf。
# 目前后两个文件是空的。为了简单起见,建议将所有的标识放在一个文件中。
# 以下两条注释的标识,是默认设置。
# 要让服务器忽略这些文件可以用 "/dev/null" (for unix)
# 或"nul" (for win32) 作为参数。
#
#resourceconfig conf/srm.conf
#accessconfig conf/access.conf

#
# timeout: 接受和发送timeout的时间
#
timeout 300

#
# keepalive: 是否允许保持连接(每个连接有多个请求)
# "off" -无效
#
keepalive on

#
# maxkeepaliverequests: 每个连接的最大请求数。
# 设置为0表示无限制
# 建议设置较高的值,以获得最好的性能。
#
maxkeepaliverequests 100

#
# keepalivetimeout: 同一连接同一客户端两个请求之间的等待时间。
#
keepalivetimeout 15

#
# 在win32下,apache每次产生一个子进程来处理请求。
# 如果这个进程死了,会自动产生另一个子进程。
# 所有的进入请求在子进程中多线程处理。
# 以下两个标识控制进程的运行
#

#
# maxrequestsperchild: 每个子进程死亡之前最大请求数
# 如果超过这个请求数,子程序会自动退出,避免延期使用导致内存溢出或其他问题。
# 大部分系统,并不需要此设置,
# 但是部分,象solaris,确实值得注意。
# 对win32, 可设置为0 (无限制)
# 除非有另外的考虑。
#
# 注: 此值不包括在每个连接初始化请求后,"keptalive"请求
# 例如, 如果一个子进程处理一个初始化请求和10个后续"keptalive"请求,
# 在这个限制下,只会记为一个请求。
#
maxrequestsperchild 0

#
# threadsperchild: 服务器所允许的并发线程数。
# 此值的设置取决于服务器的响应能力(约多的请求在同一时间激活,则每个请求的处理时间越慢)
# 和服务器所允许消耗的系统资源。
#
threadsperchild 50

#
# listen: 允许将apache绑顶到指定的ip地址和端口,作为默认值的辅助选项。
# 参见 <virtualhost>
#
#listen 3000
#listen 12.34.56.78:80

#
# bindaddress: 通过此选项可支持虚拟主机。
# 此标识用于告诉服务器监听哪个ip地址。
# 包括:"*", ip地址, 或域名.
# 参见 <virtualhost> 和 listen directives.
#
bindaddress 166.111.178.144

#
# apache模块编译成标准的windows结构。
#
# 以下模块绑定到标准的apache二进制windows分布。
# 要修改标准操作,取消以下行的注释并且修改指定模块列表。
#
# 警告:这是高级选项。可能导致服务器崩溃。
# 没有专家的指导,不要轻易修改。
#
#clearmodulelist
#addmodule mod_so.c mod_mime.c mod_access.c mod_auth.c mod_negotiation.c
#addmodule mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_userdir.c
#addmodule mod_alias.c mod_env.c mod_log_config.c mod_asis.c mod_imap.c
#addmodule mod_actions.c mod_setenvif.c mod_isapi.c

#
# 动态共享对象(dynamic shared object,dso)
#
# 要使用基于dso的功能模块,需要替换此处相应的
# `loadmodule' 行。这样在使用之前这些包含的标识都将生效。
# 有关dso及至的详细资料请看apache1.3版中的readme.dsoso。
# 运行"apche -l"将列表显示apache内奸的模块(类似标准的连接已经生效)
#
# 注:模块载入的顺序很重要。没有专家的建议,不要修改以下的顺序。
#
#loadmodule anon_auth_module modules/apachemoduleauthanon.dll
#loadmodule dbm_auth_module modules/apachemoduleauthdbm.dll
#loadmodule digest_auth_module modules/apachemoduleauthdigest.dll
#loadmodule cern_meta_module modules/apachemodulecernmeta.dll
#loadmodule digest_module modules/apachemoduledigest.dll
#loadmodule expires_module modules/apachemoduleexpires.dll
#loadmodule headers_module modules/apachemoduleheaders.dll
#loadmodule proxy_module modules/apachemoduleproxy.dll
#loadmodule rewrite_module modules/apachemodulerewrite.dll
#loadmodule speling_module modules/apachemodulespeling.dll
#loadmodule info_module modules/apachemoduleinfo.dll
#loadmodule status_module modules/apachemodulestatus.dll
#loadmodule usertrack_module modules/apachemoduleusertrack.dll

#
# extendedstatus 在服务器状态句柄被呼叫时控制是产生“完整”的状态信息(extendedstatus on)
# 还是仅返回基本信息(extendedstatus off)
# 默认是:off
#
#extendedstatus on

### 部分 2: 主服务器配置
#
# 此部分的标识用于主服务器所有的设置值,
# 响应任何<virtualhost>定义不处理的请求
# 这些值同时给你稍后在此文件中定义的<virtualhost>提供默认值。
#
# 所有的标识可能会在<virtualhost>中出现。
# 对应的默认值会被虚拟主机重新定义覆盖。
#

#
# port: standalone服务器监听的端口。
# 在apache能够监听指定端口前,需要在防火墙中进行设置。
# 其它运行httpd的服务器也可能影响此端口。 disable
# 如果遇到问题,请关闭所有的防火墙、安全保护和其他的服务。
# windos nt的"netstat -a"指令会有助于问题的分析。
#
port 80

#
# serveradmin: 你的地址。如果服务器有任何问题将发信到这个地址。
# 这个地址会在服务器产生的某些页面中出现,例如,错误报告。
#
serveradmin chenyl98@mails.tsinghua.edu.cn

#
# servername 允许设置主机名。如果与程序获得的不同,主机名将返回客户端。
# (例如,用"www"代替主机真实的名字)
#
# 注: 主机名不能随便指定。必须是你的机器有效的dns名称。否则无法正常工作。
# 如果不能理解,倾向你的网络管理员询问。
# 如果你的主机没有注册dns名,可在此输入ip地址。
# 此时必须用ip地址来访问。(如, http://123.45.67.89/)
# 这样扔可以完成重新定向的工作。
#
# 127.0.0.1 是tcp/ip的本地环路地址, 通常命名为localhost.
# 机器默认此地置为本身。 如果只是使用apache来进行本地测试和开发,
# 可使用127.0.0.1 作为服务器名.
#
#servername new.host.name

#
# documentroot: 放置服务文档的目录。
# 默认状态下,所有的请求都以这个目录为基础。
# 但是直接符号连接和别名可用于指向其他位置。
#
documentroot "d:/www_root"

#
# apache访问的每个目录可设置相关的服务和特性是允许或(和)不允许。
# (同样影响其子目录)
#
# 首先,设置"default"地址只有最基本的权限。
#
<directory />
options followsymlinks
allowoverride none
</directory>

#
# 注意从现在开始必须制定开启特殊的权限。
# 这样就不会产生意想不到的结果。
# 请仔细确认。
#

#
# 这个地址应与documentroot保持一致
#
<directory "d:/www_root">

#
# 此值可是: "none", "all", 或下列的组合: "indexes",
# "includes", "followsymlinks", "execcgi", 或 "multiviews".
#
# 注意"multiviews"必须明确指定--- "options all"不包括此特性。
#
options indexes followsymlinks multiviews

#
# 此项控制目录中哪些.htaccess文件可覆盖。
# 允许值: "all"或者以下项的组合:"options", "fileinfo",
# "authconfig", "limit"
#
allowoverride none

#
# 控制哪些用户可从此服务器获得资料。
#
order allow,deny
allow from all
</directory>

#
# userdir: 当请求~user时,追加到用户主目录的路径地址。
#
# 在win32下,并不要求指定为用户登陆的主目录。
# 因此可使用以下的格式。
# 详细参照文档userdir
#
<ifmodule mod_userdir.c>
userdir "f:/homepages/"
</ifmodule>

#
# 控制访问userdir目录. the following is an example
# 以下是一个站点的例子,权限限制为只读。
#
#<directory "e:/program files/apache group/apache/users">
# 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: 预设的html目录索引文件名。
# 用空格来分隔多个文件名。
#
<ifmodule mod_dir.c>
directoryindex
</ifmodule>

#
# accessfilename: 每个目录中用于控制访问信息的文件名。
#
accessfilename .htaccess

#
# 以下行防止客户端可访问 .htaccess 文件。
# 因为 .htaccess文件通常包含授权信息,
# 处于安全的考虑不允许访问。
# 如果想让访客看到.htaccess文件的内容,
# 可将这些行注释。
# 如果修改了上面的accessfilename,
# 请在此进行相应的修改。
#
# 同时,一般会用类似.htpasswd的文件保存密码。
# 这些文件同样可以得到保护。
#
<files ~ "^\.ht">
order allow,deny
deny from all
</files>

#
# cachenegotiateddocs: 默认下,apache对每个文档发送"pragma: no-cache"
# 这将要求代理服务器不缓存此文档。
# 取消下列行的可取消这个属性,这样代理服务器将缓存这些文档。
#
#cachenegotiateddocs

#
# usecanonicalname: (1.3新增) 当此设置为on时,
# 无论何时apache需要构建一个自引用的url(指向响应来源服务器),
# 它将用servername和port来构建一个规范的格式。
# 当此设置为off时,apache将使用客户端提供的"主机名:端口"
# 这将同时影响cgi脚本中的server_name和server_port
#
usecanonicalname on

#
# typesconfig 记录媒体类型(mime.types)文件或类似的东东放置的位置
#
<ifmodule mod_mime.c>
typesconfig conf/mime.types
</ifmodule>

#
# defaulttype 是服务器处理未确认类型的文件,如为止的扩展名,的默认类型。
# 如果你的服务器上主要包含的是文本或html文档,"text/plain"是较好的设置
# 如果服务器上主要包含二进制文件,如应用程序或图片,
# 最好设置成"application/octet-stream"防止浏览器将二进制文件以文本的方式显示。
#
defaulttype text/plain

#
# mod_mime_magic模块允许服务器使用文件自身的不同标识来确定文件类型。
# mimemagicfile指示模块文件标识的定义所在的位置。
# mod_mime_magic不是默认服务器的一部分。
# (必须自行用loadmodule来追加 [见'全局环境'部分的 dso 章节],
# 或者在编译服务器时包含mod_mime_magic部分)
# 包含在 <ifmodule> 中.
# 就是说,如果该模块是服务器的一部分,mimemagicfile标识将执行。
#
<ifmodule mod_mime_magic.c>
mimemagicfile conf/magic
</ifmodule>

#
# hostnamelookups: 注册客户端的机器名或ip地址。
# 例如: www.apache.org (on) 或 204.62.129.132 (off).
# 默认为off,因为对于网络来说,最好让人们有意识的设置为on,
# 因为开启此功能意味着每个客户请求将导致至少向name服务器发送一个lookup请求
#
hostnamelookups off

#
# errorlog: 错误记录文件的地址
# 如果不在<virtualhost>内指定errorlog
# 改虚拟主机的错误心细将记录到此处。
# 如果在<virtualhost>中明确指定了错误记录文件,
# 则错误将记录在那儿而不是这儿。
#
errorlog logs/error.log

#
# loglevel: 控制记录在error.log中信息的个数.
# 可能的值:debug, info, notice, warn, error, crit,
# alert, emerg.
#
loglevel warn

#
# 以下标识定义customlog标识使用的格式。(见下)
#
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

#
# 访问记录的位置和格式 (功用的记录文件格式).
# 如果不在<virtualhost>中定义记录文件,
# 那些访问记录就将保存在这儿。 contrariwise, if you *do*
# 反之,如果指定了记录文件,那么访问记录将记录在那儿而不是这个文件中。
#
customlog logs/access.log common

#
# 如果希望使用代理和参考的记录文件, 取消以下标识的注释符
#
#customlog logs/referer.log referer
#customlog logs/agent.log agent

#
# 如果想在一个文件中记录访问、代理、参考信息(复合的记录格式)
# 可使用以下标识
#
#customlog logs/access.log combined

#
# 在服务器产生的页面(如错误文档信息,ftp目录列表等等,不包括cgi产生的文档)中
# 增加一条服务器版本和虚拟主机名的信息。
# 设置为"email"将包含mailto: serveradmin的连接.
# 可选值: on | off | email
#
serversignature on

#
# 默认下,apache用工作行解析所有cgi脚本
# 此注释行(脚本的第一行)包括'#'和'!'后面跟着执行特殊脚本的程序路径,
# 对perl脚本来说是c:\program files\perl目录中的perl.exe。
# 工作行如下:

#!c:/program files/perl/perl

# 注意真实的工作行不能有缩进,必须是文件的第一行。
# 当然,cgi进程必须通过适当的scriptalias或execcgi选项标识来启动。
#
# 然而,windows下的apache即允许以上的unix方式,也可以通过注册表的形式。
# 用注册表执行文件的方法同在windows资源管理器中双击运行的注册方法相同。
# 此脚本操作可在windows资源管理器的“查看”菜单中设置。
# “文件夹选项”,然后查看“文件类型”。点击编辑按钮。
# 修改操作属性。apache 1.3会尝试执行‘open'操作,
# 如果失败则会尝试工作行
# 这个属性在apache release 2.0中会有改变.
#
# 每个机制都有自身特定的安全弱点,这样可能导致别人运行你不希望调用的程序。
# 最佳的解决方案还在讨论中。
#
# 要是这个windows的特殊属性生效 (同时会是unix属性无效)
# 取消下列标识的注释符。
#
#scriptinterpretersource registry
#
# 上面的标识可在<directory>块或.htaccess文件中单独替换。
# 可选择'registry' (windows behavior)或 'script'
# (unix behavior) option, 将覆盖服务器的默认值。
#

#
# aliases: 可无限制的追加别名。格式如下:
# alias 假名 真名
#
<ifmodule mod_alias.c>

#
# 注意如果假名中包含'/',服务器会在当前url中发出请求。
# 因此"/icons"不能用于别名
# 必须用 "/icons/"..
#
alias /icons/ "c:/program files/apache group/apache/icons/"

<directory "c:/program files/apache group/apache/icons">
options indexes multiviews
allowoverride none
order allow,deny
allow from all
</directory>

#
# scriptalias: 控制哪个目录包含服务器脚本。
# scriptalias本质行和aliases一样。, except that
# 区别在于真名目录中的文档被看作是一个应用程序。
# 请求时由服务器运行而不是发往客户端。
# "/"符号的规则同
# alias相同.
#
scriptalias /cgi-bin/ "c:/program files/apache group/apache/cgi-bin/"

#
# "c:/program files/apache group/apache/cgi-bin" 可修改为任何放置cgi脚本的目录
#
<directory "c:/program files/apache group/apache/cgi-bin">
allowoverride none
options none
order allow,deny
allow from all
</directory>

</ifmodule>
# 别名结束

#php脚本说明

scriptalias /php/ "d:/php/"
addtype application/x-httpd-php .php
addtype application/x-httpd-php .php3
addtype application/x-httpd-php .phtml
action application/x-httpd-php "/php/php.exe"

#php脚本说明结束

#
# redirect 允许告诉客户端服务器上曾经有的文档,但是现在不存在了。
# 并且可以告诉客户端到哪儿去寻找。
# 格式: redirect old-url new-url
#

#
# 控制服务器目录列表显示的标识
#
<ifmodule mod_autoindex.c>

#
# fancyindexing标识是使用特定的目录检索还是标准的(standard)
#
indexoptions fancyindexing

#
# addicon*表明不同文件或扩展名显示的图标。
# 这些图标只在特定检索状态下显示。
#
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 用于为制定图标的文件所显示的图标。
#
defaulticon /icons/unknown.gif

#
# adddescription在服务器生成的检索的某个文件后追加小段说明。
# 此项只在设置为fancyindexed时有效
# 格式:adddescription "描述" 文件名
#
#adddescription "gzip compressed document" .gz
#adddescription "tar archive" .tar
#adddescription "gzip compressed tar archive" .tgz

#
# readmename是服务器默认的readme文件。
# 并且会追加到目录列表的最后。
#
# headername 是目录中需要预先显示内容的文件名。
#
# 如果multiviews在选项中,作为结果,服务器将先找name.html,
# 如果存在就包含它。如果name.html不存在,
# 服务器会继续寻找name.txt。如果存在就作为纯文本包含进来。
#
readmename readme
headername header

#
# indexignore是一系列的文件名。目录索引将忽略这些文件并且不包含在列表中。
# 允许使用通配符。
#
indexignore .??* *~ *# header* readme* rcs cvs *,v *,t

</ifmodule>
# indexing标识结束

#
# 文件类型
#
<ifmodule mod_mime.c>

#
# addencoding 可用于特殊浏览器(mosaic/x 2.1+)快速传输压缩信息。
# 注:并不是所有的服务器都支持。
# 除了名字相似,以下add*标识对上面的fancyindexing定制标识无影响。
#
addencoding x-compress z
addencoding x-gzip gz tgz
#
# addlanguage用于指定文档的语言。
# 可以使用content标签指定每个文件的语言。
#
# 注 1: 后缀不必与所用语言的关键字相同。
# --- 波兰语(polish,标准代码为pl)的文档可以用
# "addlanguage pl .po" 来避免与perl脚本文件混淆。
#
# 注 2: 以下例子表明两个字母的语言缩写和两个字母的国家缩写并不一定相同。
# e.g. 'danmark/dk' 对比 'danish/da'.
#
# 注 3: 其中'ltz'使用了三个字符,与rfc的规定不同。
# 但是这个问题正在修订中,并且重新清理rfc1766
#
# 丹麦danish (da) - 荷兰dutch (nl) - 英国english (en) - 爱萨尼亚estonian (ee)
# 法国french (fr) - 德国german (de) - 现代希腊文greek-modern (el)
# 意大利italian (it) - 朝鲜korean (kr) - 挪威norwegian (no)
# 葡萄牙portuguese (pt) - 卢森堡luxembourgeois* (ltz)
# 西班牙spanish (es) - 瑞典swedish (sv) - 加泰罗尼亚catalan (ca) - 捷克czech(cz)
# 波兰polish (pl) - 巴西brazilian portuguese (pt-br) - 日本japanese (ja)
# 俄国russian (ru)
#
addlanguage da .dk
addlanguage nl .nl
addlanguage en .en
addlanguage et .ee
addlanguage fr .fr
addlanguage de .de
addlanguage el .el
addlanguage he .he
addcharset iso-8859-8 .iso8859-8
addlanguage it .it
addlanguage ja .ja
addcharset iso-2022-jp .jis
addlanguage kr .kr
addcharset iso-2022-kr .iso-kr
addlanguage no .no
addlanguage pl .po
addcharset iso-8859-2 .iso-pl
addlanguage pt .pt
addlanguage pt-br .pt-br
addlanguage ltz .lu
addlanguage ca .ca
addlanguage es .es
addlanguage sv .se
addlanguage cz .cz
addlanguage ru .ru
addlanguage tw .tw
addcharset big5 .big5 .big5
addcharset windows-1251 .cp-1251
addcharset cp866 .cp866
addcharset iso-8859-5 .iso-ru
addcharset koi8-r .koi8-r
addcharset ucs-2 .ucs2
addcharset ucs-4 .ucs4
addcharset utf-8 .utf8

# languagepriority 可设置语言的优先级。
#
# 优先级降序排列
# 在此处按照字母顺序,可自行修改
#
<ifmodule mod_negotiation.c>
languagepriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
</ifmodule>

#
# addtype 可临时改变mime.types或者指定特殊文件的格式。
#
# 例如:php 3.x 模块 (非apache标准配件,参见http://www.php.net)可用下面格式定义:
#
#addtype application/x-httpd-php3 .php3
#addtype application/x-httpd-php3-source .phps
#
# php 4.x, 使用:
#
#addtype application/x-httpd-php .php
#addtype application/x-httpd-php-source .phps

addtype application/x-tar .tgz

#
# addhandler 可将特定文件扩展名映射到处理方法上。
# 与文件类型无关。此特性可内建到服务器中或者追加在操作指令中(见下)
#
# 如果希望用服务器端应用或scriptaliased外的cgi,取消以下行的注释符
#
# 用cgi脚本:
#
#addhandler cgi-script .cgi

#
# 用服务器解析的html文档
#
#addtype text/html .shtml
#addhandler server-parsed .shtml

#
# 取消以下注释符可激活apache的send-asis http file特性
#
#addhandler send-as-is asis

#
# 如果使用服务器端解析的图像定位文件,使用以下标识:
#
#addhandler imap-file map

#
# 要激活type maps使用:
#
#addhandler type-map var

</ifmodule>
# 文档类型说明结束

#
# action 定义在文件匹配时执行相应的脚本。
# 可简化常用cgi文件的调用。
# 格式: action media/type /cgi-script/location
# 格式: action handler-name /cgi-script/location
#

#
# metadir: 指定保存meta信息文件的目录。
# 这些文件包含附加的http头,在发送文档是一并发送。
#
#metadir .web

#
# metasuffix: 指定包含meta信息的文件的后缀。
#
#metasuffix .meta

#
# 可定制的错误响应(apache类型)
# 共三种风格:
#
# 1) 纯文本
#errordocument 500 "the server made a boo boo.
# 注: 第一个"号用于表示是文本,实际不输出
#
# 2) 本地重定向
#errordocument 404 /missing.html
# to redirect to local url /missing.html
#errordocument 404 /cgi-bin/missing_handler.pl
# 注:可重定向到任何一个服务器端的脚本或文档
#
# 3) 外部重定向
#errordocument 402 http://some.other_server.com/subscription_info.html
# 注: 大部分与初始请求关联的环境变量对这样的脚本无效。
#

#
# 基于浏览器的定制操作
#
<ifmodule mod_setenvif.c>

#
# 以下标识修改普通的http响应操作。
# 第一个标识针对netscape2.x和其他无此功能的浏览器取消保持激活状态的功能
# 这些浏览器在执行这些功能时会出错。
# 第二个标识针对ie4.0b2设置。其中有一条不完整的http/1.1指令
# 在301或302(重定向)响应时不能正确的保持激活状态
#
browsermatch "mozilla/2" nokeepalive
browsermatch "msie 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

#
# 下面的标识通过不产生基本的1.1响应取消对违反http/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

</ifmodule>
# 浏览器定制标识结束

#
# 允许使用url"http://servername/server-status"的形式查看服务器状态报告
# 修改 ".your_domain.com"来匹配相应的域名以激活此功能
#
#<location /server-status>
# sethandler server-status
# order deny,allow
# deny from all
# allow from .your_domain.com
#</location>

#
# 允许使用url"://servername/server-info"(要求加载mod_info.c),
# 来远程察看服务器配置报告。
# 修改 ".your_domain.com"来匹配相应的域名以激活此功能
#
#<location /server-info>
# sethandler server-info
# order deny,allow
# deny from all
# allow from .your_domain.com
#</location>

#
# 据报有人试图利用一个老的1.1漏洞。
# 这个漏洞与cgi脚本在apache服务器上分布有关。
# 通过取消下面几行的注释符,可以将此类攻击记录转移到phf.apache.org上的记录脚本上。
# 或者也可以利用脚本scriptsupport/phf_abuse_log.cgi记录在本地服务器上。
#
#<location /cgi-bin/phf*>
# deny from all
# errordocument 403 http://phf.apache.org/phf_abuse_log.cgi
#</location>

#
# 代理服务器标识。取消下列行的注释符可激活代理服务器。
#
#<ifmodule mod_proxy.c>
# proxyrequests on

# <directory proxy:*>
# order deny,allow
# deny from all
# allow from .your_domain.com
# </directory>

#
# 激活/取消处理http/1.1 "via:" 报头
# ("full":加入服务器版本; "block":取消所有外发的via: 报头)
# 可设置值: off | on | full | block
#
# proxyvia on

#
# 可修改下列各行并取消注释符来激活缓存。
# (没有cacheroot标识就不使用缓存)
#
# cacheroot "e:/program files/apache group/apache/proxy"
# cachesize 5
# cachegcinterval 4
# cachemaxexpire 24
# cachelastmodifiedfactor 0.1
# cachedefaultexpire 1
# nocache a_domain.com another_domain.edu joes.garage_sale.com

#</ifmodule>
# 代理标识结束

### 部分 3: 虚拟主机
#
# 虚拟主机: 如果希望在一台服务器上实现多个域名和主机名的服务,
# 可设置virtualhost来实现。most configurations
# 大部分的设置使用基于名称的虚拟主机,这样服务器就不必为ip地址操心。
# 这些用星号在下面的标识中标出。
#
# 在试图设置虚拟主机前
# 请阅读<url:http://www.apache.org/docs/vhosts/>中的文档。
# 以了解细节问题。
#
# 可用命令行参数 '-s'来确认虚拟主机的设置。
#

#
# 使用基于名称的虚拟主机
#
#namevirtualhost *

#
# 虚拟主机实例:
# 几乎所有的apache标识都可用于虚拟主机内。
# 第一个virtualhost部分用于申请一个无重复的服务器名。
#
#<virtualhost *>
# serveradmin webmaster@dummy-host.example.com
# documentroot /www/docs/dummy-host.example.com
# servername dummy-host.example.com
# errorlog logs/dummy-host.example.com-error_log
# customlog logs/dummy-host.example.com-access_log common
#</virtualhost>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网