apache 的配置檔案hthp.conf裡邊都是什麼意思?
阿新 • • 發佈:2019-02-11
備份參考1:
1、配置檔案概述
1>Apache的配置檔案是包含若干指令的純文字檔案。主配置檔案通常叫httpd.conf ,其位置是編譯時確定的,但可以用命令列引數 -f 來改變。Apache配置檔案的每一行包含一個指令,在行尾使用反斜槓"\"可以表示續行,但是反斜槓與下一行之間不能有任何其他字元(包括空白字元)。配置檔案中的指令是不區分大小寫的,但是指令的引數(argument)通常是大小寫敏感的。以"#"開頭的行被視為註解並被忽略。註解不能出現在指令的後邊。空白行和指令前的空白字元將被忽略,因此可以採用縮排以保持配置層次的清晰。主配置檔案更改後重新啟動Apache後才會生效。可以用 apachectl configtest 或者命令列選項 -t 檢查配置檔案中的錯誤,而無須啟動Apache伺服器。
2>配置檔案中可以用Include指令和萬用字元附加許多其他配置檔案。任何配置檔案都可以使用任何指令。
3>伺服器還會讀取一個包含MIME檔案型別的檔案,其檔名由TypesConfig指令確定,預設值是mime.types。
4>Apache是模組化的伺服器,這意味著核心中只包含實現最基本功能的模組。擴充套件功能可以作為模組動態載入。預設情況下,只有base組的模組被編譯進了伺服器。如果伺服器在編譯時包含了DSO模組,那麼各模組可以獨立編譯,並可隨時用LoadModule指令載入;否則,要增加或刪除模組必須重新編譯整個Apache。用於特定模組的指令可以用指令包含起來,使之有條件地生效。命令列引數 -l 可以檢視已經編譯到伺服器中的模組。
2 、配置檔案說明
###################檔案說明###################
# This is the main Apache HTTP 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.
#
# 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.
###################配置說明##########################
# 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 "/usr/local/apache" will be interpreted by the
# server as "/usr/local/apache/logs/foo_log".
#如果包含的配置檔案以根目錄/開始,則使用指出的明確路徑,要是非根目錄開始,則路徑為:查詢路徑=ServerRoot目錄+所寫目錄
##################軟體主目錄################
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk. If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
#ServerRoot:服務配置檔案,日誌,錯誤日誌等的根目錄,即軟體所在目錄。
#注意不要再目錄後加/,如果目錄非本地磁碟,要先在本地磁碟使用LockFile指令來指明。如果要為多個httpd程式共享根目錄,需要至少改變LockFile和PidFile。即,要保證apache的程序檔案的獨佔性。
ServerRoot "/usr/local/apache"
#################監聽埠和IP############################
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
#apache程式執行的監聽IP地址和埠,即http訪問地址+埠,預設80
Listen 80
#####################要載入的DSO模組##########################
#
# 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.
#需要動態載入的DSO模組寫在這裡以使程式啟動時載入。格式如例子所述,靜態編譯的模組不需要寫在這裡,由httpd -l來載入靜態模組
# Example:
# LoadModule foo_module modules/mod_foo.so
#
#非NetWare和winnt模式下
#
# 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.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
####################軟體執行使用者設定###################
#如果要更換不同的使用者或組來執行apache,你必須先以root執行,然後他將會切換到所設定使用者。跟大多數的系統服務一樣,為apache單獨建立一個使用者和組來執行它是一個很好的做法。(注意,此項是設定在非NetWare和非win系統下才需配置,否則無需配置)
User daemon
Group daemon
######################Apache主配置部分###############
###############概要說明##########
# '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
# definition. These values also provide defaults for
# any containers you may define later in the file.
#
# All of these directives may appear inside containers,
# 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
# as error documents. e.g. [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.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#伺服器域名指定。這裡一般可以自動識別,也可以給出域名和埠以明確指定(虛擬主機多用此選項),如果沒有註冊DNS,可以使用IP地址。
#ServerName www.example.com:80
################網站根目錄#############
# 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 "/usr/local/apache/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.
#
#Options指令控制了在特定目錄中將使用哪些伺服器特性。其值如下:None All Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#option可以為None ,在這種情況下,將不啟用任何額外特性。或設定為以下選項中的一個或多個:
#All :除MultiViews之外的所有特性。這是預設設定。
#ExecCGI:允許使用mod_cgi執行CGI指令碼。
#FollowSymLinks:伺服器允許在此目錄中使用符號連線。 注意:即使伺服器會使用符號連線,但它不會改變用於匹配段的路徑名。
#Includes:允許使用mod_include提供的伺服器端包含。
#IncludesNOEXEC:允許伺服器端包含,但禁用"#exec cmd"和"#exec cgi"。但仍可以從ScriptAlias目錄使用"#include virtual"虛擬CGI指令碼。
#Indexes:如果一個對映到目錄的URL被請求,而此目錄中又沒有DirectoryIndex(例如:index.html),那麼伺服器會返回由mod_autoindex生成的一個格式化後的目錄列表。
#MultiViews:允許使用mod_negotiation提供內容協商的"多重檢視"(MultiViews)。
#SymLinksIfOwnerMatch:伺服器僅在符號連線與其目的目錄或檔案的擁有者具有相同的uid時才使用它。
#一般來說,如果一個目錄被多次設定了Options ,則最特殊的一個會被完全接受(其它的被忽略),而各個可選項的設定彼此並不融合。然而,如果所有作用於Options指令的可選項前都加有"+"或"-"符號,此可選項將被合併。所有前面加有"+"號的可選項將強制覆蓋當前的可選項設定,而所有前面有"-"號的可選項將強制從當前可選項設定中去除。
#AllowOverride指令控制允許存在於.htaccess檔案中的指令型別,其值如下:Options FileInfo AuthConfig Limit All None
#當伺服器發現一個.htaccess檔案(由AccessFileName指定)時,它需要知道在這個檔案中宣告的哪些指令能覆蓋在此之前指定的配置指令。AllowOverride僅在不包含正則表示式的配置段中才是有效的。在, , 配置段中都是無效的。如果此指令被設定為None ,那麼.htaccess檔案將被完全忽略。事實上,伺服器根本不會讀取.htaccess檔案。當此指令設定為 All時,所有具有".htaccess"作用域的指令都允許出現在.htaccess檔案中。
#選項:
#AuthConfig:允許使用與認證授權相關的指令(AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, 等)。
#FileInfo:允許使用控制文件型別的指令(DefaultType, ErrorDocument, ForceType, LanguagePriority, SetHandler, SetInputFilter, SetOutputFilter, mod_mime中的 Add* 和 Remove* 指令等等)、控制文件元資料的指令(Header, RequestHeader, SetEnvIf, SetEnvIfNoCase, BrowserMatch, CookieExpires, CookieDomain, CookieStyle, CookieTracking, CookieName)、mod_rewrite中的指令(RewriteEngine, RewriteOptions, RewriteBase, RewriteCond, RewriteRule)和mod_actions中的Action指令。
#Indexes:允許使用控制目錄索引的指令(AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon, DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions, ReadmeName, 等)。
#Limit:允許使用控制主機訪問的指令(Allow, Deny, Order)。
#Options[=Option,...]允許使用控制指定目錄功能的指令(Options和XBitHack)。可以在等號後面附加一個逗號分隔的(無空格的)Options選項列表,用來控制允許Options指令使用哪些選項。
#Order指令:控制是否允許從伺服器上獲取東西,即控制預設的訪問狀態與Allow和Deny指令生效的順序
#Allow指令:控制哪些主機能夠訪問伺服器
#Deny指令:控制哪些主機被禁止訪問伺服器
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
#
# 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.
#此處用於更改你將要設定的站點根目錄
#
# 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
#
# 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
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
####################網站主頁索引##############
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#在目錄被請求是查詢的主檔案。即設定網站主頁格式。
DirectoryIndex index.html
###################ht檔案等是否被檢視設定##############
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#如下配置保護正則表示式中所描述的檔案不被web所檢視
#Satisfy指令:同時使用Allow和Require時的訪問策略。引數可以設定為 All 或 Any 。這個指令僅在某個特定區域的訪問控制同時被使用者名稱/密碼和客戶端主機地址進行限定的時候起作用。預設行為(All)採取客戶端首先通過地址訪問限制並且輸入有效的使用者名稱和密碼的方式。使用可選項 Any 將使客戶端在通過主機限制或是輸入一個有效的使用者名稱和密碼兩種方式之一得到訪問許可權。這樣,就可以通過密碼來限制一個區域的訪問,但允許某些特定地址的客戶端訪問時不需要輸入密碼。
Order allow,deny
Deny from all
Satisfy All
#################錯誤日誌儲存地點##############
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a
# 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,
# alert, emerg.
#控制記錄到日誌的訊息的級別。可選值有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).
#
#下面的指令定義了一些為使用者指令而使用的別名的格式。Apache配置中,LogFormat可用變數格式字串 描述
#%% 百分號(Apache2.0.44或更高的版本)
#%a 遠端IP地址
#%A 本機IP地址
#%B 除HTTP頭以外傳送的位元組數
#%b 以CLF格式顯示的除HTTP頭以外傳送的位元組數,也就是當沒有位元組傳送時顯示'-'而不是0。
#%{Foobar}C 在請求中傳送給服務端的cookieFoobar的內容。
#%D 伺服器處理本請求所用時間,以微為單位。
#%{FOOBAR}e 環境變數FOOBAR的值
#%f 檔名
#%h 遠端主機
#%H 請求使用的協議
#%{Foobar}i 傳送到伺服器的請求頭Foobar:的內容。
#%l 遠端登入名(由identd而來,如果支援的話),除非IdentityCheck設為"On",否則將得到一個"-"。
#%m 請求的方法
#%{Foobar}n 來自另一個模組的註解Foobar的內容。
#%{Foobar}o 應答頭Foobar:的內容。
#%p 伺服器服務於該請求的標準埠。
#%P 為本請求提供服務的子程序的PID。
#%{format}P 服務於該請求的PID或TID(執行緒ID),format的取值範圍為:pid和tid(2.0.46及以後版本)以及hextid(需要APR1.2.0及以上版本)
#%q 查詢字串(若存在則由一個"?"引導,否則返回空串)
#%r 請求的第一行
#%s 狀態。對於內部重定向的請求,這個狀態指的是原始請求的狀態,---%>s則指的是最後請求的狀態。
#%t 時間,用普通日誌時間格式(標準英語格式)
#%{format}t 時間,用strftime(3)指定的格式表示的時間。(預設情況下按本地化格式)
#%T 處理完請求所花時間,以秒為單位。
#%u 遠端使用者名稱(根據驗證資訊而來;如果返回status(%s)為401,可能是假的)
#%U 請求的URL路徑,不包含查詢字串。
#%v 對該請求提供服務的標準ServerName。
#%V 根據UseCanonicalName指令設定的伺服器名稱。
#%X 請求完成時的連線狀態:X= 連線在應答完成前中斷。
#+= 應答傳送完後繼續保持連線。
#-= 應答傳送完後關閉連線。
#(在1.3以後的版本中,這個指令是%c,但這樣就和過去的SSL語法:%{var}c衝突了)
#%I 接收的位元組數,包括請求頭的資料,並且不能為零。要使用這個指令你必須啟用mod_logio模組。
#%O 傳送的位元組數,包括請求頭的資料,並且不能為零。要使用這個指令你必須啟用mod_logio模組。
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
# You need to enable mod_logio.c to use %I and %O
#使用此模組要載入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
# container, they will be logged here. Contrariwise, if you *do*
# define per- access logfiles, transactions will be
# logged therein and *not* in this file.
#訪問日誌檔案(普通檔案格式)的位置。如果虛擬主機內定義了,則使用虛擬主機的定義,否則使用此處的定義
CustomLog "logs/access_log" common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#如果您喜歡訪問代理日誌檔案和referer資訊(綜合日誌檔案格式),你可以使用下面的指令。
#CustomLog "logs/access_log" combined
#############################域名重定向設定#####################
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar
#重定向:允許你告訴曾經存在於您的伺服器的網站文件,但不是現在。客戶端會收到那個舊檔案所在的新位置。
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#對映web路徑到檔案系統路徑下,用於訪問那些不在網站根目錄下的檔案
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a section to allow access to
# the filesystem path.
#如果你使用站點路徑,伺服器將請求現存的url路徑,你可能需要提供個 部分以允許訪問物理路徑。
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target 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指令:此控制哪個目錄包含伺服器指令碼。
#ScriptAliases實質上基本與別名相同,除了在目標目錄中的檔案當發生請求訪問時被視為應用程式並在伺服器執行,而不是檔案被髮送到客戶端。對尾隨同樣的規則“/”適用於在ScriptAlias指令和Alias。
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
############################CGI守護程序設定####################
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#ScriptSock:線上程伺服器上,指定的路徑到UNIX介面可以用來與mod_cgid的CGI守護程序通訊。
#Scriptsock logs/cgisock
#
# "/usr/local/apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#如果配置了ScriptAliased,要把"/usr/local/apache/cgi-bin"改成你的ScriptAliased CGI所在的目錄
AllowOverride None
Options None
Order allow,deny
Allow from all
#######################MIME型別設定######################
# DefaultType: 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.
#預設型別:如果伺服器不能從副檔名決定文件型別,將使用此處定義的預設型別。如果伺服器包含了很多文字或html文件"text/plain" 是一個很好的值。如果你的內容大部分是二進位制檔案,例如應用程式或映象,你可以使用"application/octet-stream" 來使瀏覽器顯示為二進位制檔案型別。
DefaultType text/plain
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#TypesConfig列表指明通過副檔名所對映的MIME型別
TypesConfig conf/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#AddType允許你新增或覆蓋在TypesConfig中所指定的檔案型別的MIME型別的配置
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#AddEncoding允許你使某些瀏覽器在傳輸過程中解壓資訊。注意:不是所有瀏覽器都支援。
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#如果如上的AddEncoding指令註釋掉了,你可能應該定義這些擴充套件媒體型別說明
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#AddHandler允許某些副檔名對映到“handlers”:行為無關的檔案型別。這些可以是內建到伺服器或操作指令增加(見下文)。要使用ScriptAliased目錄以外的CGI指令碼的(你還需要新增“ExecCGI”到“Options”指令。)
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):為型別對映(談判源)
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#過濾器允許內容被髮送到客戶端前被處理。為在解析.shtml檔案伺服器端包含(ssl)檔案。(你也需要新增Include到Options指令中)
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
#
# 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指令告訴模組在哪裡找到暗示定義的位置。
#MIMEMagicFile conf/magic
#########################訪問錯誤重定向######################
# 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
#
########################MMAP設定####################
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
#EnableMMAP和EnableSendfile:在支援它的系統上,記憶體對映或傳送檔案系統呼叫是用來提供檔案系統。這通常提供了伺服器效能,再在關閉時必須從掛載的檔案系統或者所支援該功能的函式中儲存,否則可能損壞您的系統。
#EnableMMAP off
#EnableSendfile off
############################其他匯入的配置檔案################
# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.
#參考配置
#在conf/extra目錄下的配置檔案可以新增特性或者修改伺服器上的預設配置,或者你可以簡單的拷貝內容然後根據需要更改。
# Server-pool management (MPM specific)伺服器池管理(MPM)
#Include conf/extra/httpd-mpm.conf
# Multi-language error messages多語言錯誤資訊
#Include conf/extra/httpd-multilang-errordoc.conf
# Fancy directory listings目錄列表
#Include conf/extra/httpd-autoindex.conf
# Language settings語言設定
#Include conf/extra/httpd-languages.conf
# User home directories使用者目錄設定
#Include conf/extra/httpd-userdir.conf
# Real-time info on requests and configuration實時資訊的要求和配置
#Include conf/extra/httpd-info.conf
# Virtual hosts虛擬主機配置
#Include conf/extra/httpd-vhosts.conf
# Local access to the Apache HTTP Server Manual本地訪問Apache HTTP伺服器手冊
#Include conf/extra/httpd-manual.conf
# Distributed authoring and versioning (WebDAV)WebDAV配置
#Include conf/extra/httpd-dav.conf
# Various default settings各種預設設定
#Include conf/extra/httpd-default.conf
#############################SSL設定###############################
# Secure (SSL/TLS) connections加密連線設定
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
# starting without SSL on platforms with no /dev/random equivalent
# but a statically compiled-in mod_ssl.
#注意:要支援如下功能必須存在在沒有ssl的平臺上(和no /dev/random 等價),而是靜態編譯了mod_ssl。
#偽隨機數生成器(PRNG)播種源
SSLRandomSeed startup builtin使用內建方式啟動
SSLRandomSeed connect builtin使用內建方式連線
3、附加配置檔案說明
httpd-autoindex.conf(控制目錄列表顯示)
#
# Directives controlling the display of server-generated directory listings.
#這些指令控制伺服器顯示生成的目錄列表,需要mod_autoindex, mod_alias模組
# Required modules: mod_autoindex, mod_alias
#
# To see the listing of a directory, the Options directive for the
# directory must include "Indexes", and the directory must not contain
# a file matching those listed in the DirectoryIndex directive.
#要檢視一個目錄列表,目錄的Options指令必須包括“索引”,並且目錄不能包含一個DirectoryIndex指令列出的檔案。
#
# IndexOptions: Controls the appearance of server-generated directory
# listings.
#IndexOptions控制伺服器目錄列表的生成
IndexOptions FancyIndexing HTMLTable VersionSort
# We include the /icons/ alias for FancyIndexed directory listings. If
# you do not use FancyIndexing, you may comment this out.
#通過使用為/icons/為目錄列表做別名。如果不使用FancyIndexing,則註釋掉此項。
Alias /icons/ "/usr/local/apache/icons/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
#
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions. These are only displayed for
# FancyIndexed directories.
#AddIcon *指令告訴伺服器顯示不同的檔案或副檔名的圖示。這只是為顯示FancyIndexed指令
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
# explicitly set.
#設定預設的(即不識別的副檔名)圖示。
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允許您為伺服器上在檔案中生成的索引建立一個簡短的說明。這只是顯示為FancyIndexed指令。格式: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檔案的名稱,伺服器預設情況下將尋找並追加到目錄列表。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要忽略的檔案。允許使用shell的萬用字元
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
httpd-vhosts.conf(虛擬主機配置)
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#如果要保留多個域名/主機 在你的伺服器上,你可以為它們設定虛擬主機。大部分的配置使用基於域名的虛擬主機,所以不需要擔心IP地址問題,這一點可以在下面通過星號來表示。
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#你可以使用-S指令來驗證你的虛擬主機檔案配置。
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#虛擬主機示例:大部分的Apache指令可以放在虛擬主機容器中。第一個就是個模板。
ServerAdmin [email protected]
DocumentRoot "/usr/local/apache/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
ServerAdmin [email protected]
DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
httpd-userdir.conf(使用者主目錄作為網站)
# Settings for user home directories
#
# Required module: mod_userdir
#使用者主目錄設定:目錄名是當一個請求到達時追加到使用者的家目錄。注意你必須為這些目錄設定預設的訪問控制
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received. Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir public_html
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#使用者目錄的控制訪問。下面是個例子
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
Order deny,allow
Deny from all
#參考http://www.phpchina.com/manual/apache/mod/mod_userdir.html
httpd-manual.conf(伺服器檔案訪問)
#在伺服器上提供檔案訪問
# Provide access to the documentation on your server as
# http://yourserver.example.com/manual/
# The documentation is always available at
# http://httpd.apache.org/docs/2.2/
#
# Required modules: mod_alias, mod_setenvif, mod_negotiation
#
AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|pt-br|ru|tr))?(/.*)?$ "/usr/local/apache/manual$1"
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
SetHandler type-map
# .tr is text/troff in mime.types!
ForceType text/html
SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|pt-br|ru|tr)/ prefer-language=$1
RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|pt-br|ru|tr)){2,}(/.*)?$ /manual/$1$2
LanguagePriority en de es fr ja ko pt-br ru tr
#可用語言型別
ForceLanguagePriority Prefer Fallback
#首先從上面取一個可用的語言型別,若找不到,則機器試圖使用最接近的語言
httpd-dav.conf(DAV配置)
#
# Distributed authoring and versioning (WebDAV)
#
# Required modules: mod_dav, mod_dav_fs, mod_setenvif, mod_alias
# mod_auth_digest, mod_authn_file
#
# The following example gives DAV write access to a directory called
# "uploads" under the ServerRoot directory.
# 下面的例子給出了使用DAV在根目錄下上傳檔案的例子。在httpd.conf中指定的使用者或組需要對DavLockDB中的目錄有寫許可權,並且在任何目錄中,要指定Dav On
# The User/Group specified in httpd.conf needs to have write permissions
# on the directory where the DavLockDB is placed and on any directory where
# "Dav On" is specified.
DavLockDB "/usr/local/apache/var/DavLock"
Alias /uploads "/usr/local/apache/uploads"
Dav On
Order Allow,Deny
Allow from all
AuthType Digest
AuthName DAV-upload
# You can use the htdigest program to create the password database:
# htdigest -c "/usr/local/apache/user.passwd" DAV-upload admin
#你可以使用htdigest程式建立個密碼資料庫。
AuthUserFile "/usr/local/apache/user.passwd"
AuthDigestProvider file
# Allow universal read-access, but writes are restricted
# to the admin user.
#允許普遍讀訪問,但僅限於寫的管理員使用者
require user admin
#
# The following directives disable redirects on non-GET requests for
# a directory that does not include the trailing slash. This fixes a
# problem with several clients that do not appropriately handle
# redirects for folders with DAV methods.
#下面的指令禁用了在對不包括尾部有斜線的目錄非get請求的重定向。這些修正了一些客戶端不能對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
httpd-info.conf(伺服器資訊報告)
#
# Get information about the requests being processed by the server
# and the configuration of the server.
# 獲取伺服器當前處理的請求和伺服器配置的資訊
# Required modules: mod_status (for the server-status handler),
# mod_info (for the server-info handler)
#允許使用網址http://servername/server-status通過mod_status生成伺服器狀態報告。
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
SetHandler server-status
Order deny,allow
Deny from all
Allow from .example.com
#
# 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控制apache是否允許生成全部的狀態資訊。on生成所有資訊,off是基本資訊,預設off。
#ExtendedStatus On
#允許通過網址 http://servername/server-info顯示遠端伺服器配置報告
# Allow remote server configuration reports, with the URL of
# http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".example.com" to match your domain to enable.
#
SetHandler server-info
Order deny,allow
Deny from all
Allow from .example.com
httpd-default.conf(http預設引數)
#
# This configuration file reflects default settings for Apache HTTP Server.
#
# You may change these, but chances are that you may not need to.
#這個配置檔案反應的是apache的預設配置,但是一般可能用不到
#
# Timeout: The number of seconds before receives and sends time out.
#在收到和傳送前的超時時間
Timeout 300
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#是否允許持續連線。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.
#允許在一個持續連線中最大的請求數量。0不限制。為了效能,不建議設定的數值太高。
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#等待來自同一個連線的同一個客戶端的下一個請求的秒數
KeepAliveTimeout 5
#
# 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指令:決定Apache如何構造自引用的URL和SERVER_NAME和SERVER_PORT變數。當設定為“關閉”,Apache會使用由客戶提供的主機名和埠。當設定為“On”,Apache會使用ServerName指令的值。
UseCanonicalName Off
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#需要在目錄中額外配置指令的檔案。
AccessFileName .htaccess
#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'Full' which sends information about the OS-Type
# and compiled in modules.
# Set to one of: Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#該指令配置伺服器HTTP響應頭返回內容。預設值為'全部'這發出關於作業系統的型別和模組編譯的資料。可選值有Full | OS | Minor | Minimal | Major | Prod,full最多,prod最少。
ServerTokens Full
#
# 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
#可以選擇性的新增一行包含伺服器版本和虛擬主機名的生成頁面(包含內部錯誤文件,ftp目錄列表,mod_status和mod_info輸出等,但是不包括CGI生成文件或者使用者錯誤文件)。Email選項會發送郵件給伺服器管理員。
ServerSignature On
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off