亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
首頁(yè) 版本說(shuō)明 從1.3升級(jí)到2.0 編譯時(shí)配置的改變 運(yùn)行時(shí)配置的改變 雜項(xiàng)變化 第三方模塊 從 2.0 升級(jí)到 2.2 編譯時(shí)配置的改變 運(yùn)行時(shí)配置的改變 雜項(xiàng)變化 第三方模塊 Apache 2.1/2.2 版本的新特性 核心增強(qiáng) 模塊增強(qiáng) 程序增強(qiáng) 針對(duì)模塊開(kāi)發(fā)者的變化 Apache 2.0 版本的新特性 核心的增強(qiáng) 模塊的增強(qiáng) Apache許可證 參考手冊(cè) 編譯與安裝 針對(duì)心急者的概述 要求 下載 解壓 配置源代碼樹(shù) 編譯 安裝 配置 測(cè)試 升級(jí) 啟動(dòng) Apache是怎樣啟動(dòng)的 啟動(dòng)時(shí)發(fā)生錯(cuò)誤 隨系統(tǒng)啟動(dòng)時(shí)啟動(dòng) 額外信息 停止與重新啟動(dòng) 簡(jiǎn)介 立即停止 優(yōu)雅重啟 立即重啟 優(yōu)雅停止 附錄:信號(hào)和競(jìng)爭(zhēng)條件 運(yùn)行時(shí)配置指令 主配置文件 配置文件的語(yǔ)法 模塊 指令的作用域 .htaccess文件 配置段 配置段(容器)的類型 文件系統(tǒng)和網(wǎng)絡(luò)空間 虛擬主機(jī) 代理 允許使用哪些指令? 配置段的合并 內(nèi)容緩沖 簡(jiǎn)介 緩沖概述 安全方面的考慮 文件句柄緩沖 內(nèi)存緩沖 磁盤(pán)緩沖 服務(wù)器全局配置 服務(wù)器標(biāo)識(shí) 文件定位 限制資源的使用 日志文件 安全警告 錯(cuò)誤日志 訪問(wèn)日志 日志滾動(dòng) 管道日志 虛擬主機(jī) 其他日志文件 從URL到文件系統(tǒng)的映射 相關(guān)模塊和指令 DocumentRoot DocumentRoot以外的文件 用戶目錄 URL重定向 反向代理 重寫(xiě)引擎 File Not Found 安全方面的提示 保持不斷更新和升級(jí) ServerRoot目錄的權(quán)限 服務(wù)器端包含 關(guān)于CGI 未指定為腳本的CGI 指定為腳本的CGI 其他動(dòng)態(tài)內(nèi)容的來(lái)源 系統(tǒng)設(shè)置的保護(hù) 默認(rèn)配置下服務(wù)器文件的保護(hù) 觀察日志文件 動(dòng)態(tài)共享對(duì)象(DSO) 實(shí)現(xiàn) 用法概要 背景知識(shí) 優(yōu)點(diǎn)和缺點(diǎn) 內(nèi)容協(xié)商 關(guān)于內(nèi)容協(xié)商 Apache中的內(nèi)容協(xié)商 協(xié)商的方法 打亂品質(zhì)值 透明內(nèi)容協(xié)商的擴(kuò)展 超鏈和名稱轉(zhuǎn)換說(shuō)明 緩沖說(shuō)明 更多信息 自定義錯(cuò)誤響應(yīng) 行為 配置 自定義錯(cuò)誤響應(yīng)與重定向 地址和端口綁定 概述 針對(duì)IPv6的特殊考慮 怎樣與虛擬主機(jī)協(xié)同工作 多路處理模塊(MPM) 簡(jiǎn)介 選擇一個(gè)MPM 默認(rèn)的MPM 環(huán)境變量 設(shè)置環(huán)境變量 使用環(huán)境變量 用于特殊目的的環(huán)境變量 示例 處理器的使用 什么是處理器? 例子 程序員注意事項(xiàng) 過(guò)濾器 Apache2中的過(guò)濾器 智能過(guò)慮 使用過(guò)濾器 CGI腳本的Suexec執(zhí)行 開(kāi)始之前 suEXEC的安全模型 配置和安裝suEXEC 啟用和禁用suEXEC 使用suEXEC 調(diào)試suEXEC 謹(jǐn)防Jabberwock:警告和舉例 性能調(diào)整 硬件和操作系統(tǒng) 運(yùn)行時(shí)的配置 編譯時(shí)的配置 附錄:蹤跡的詳細(xì)分析 URL重寫(xiě)指南 mod_rewrite簡(jiǎn)介 實(shí)踐方案 URL的規(guī)劃 內(nèi)容的處理 對(duì)訪問(wèn)的限制 其他 虛擬主機(jī)文檔 總述 虛擬主機(jī)支持 配置指令 基于主機(jī)名的虛擬主機(jī) 基于域名的虛擬主機(jī)和基于IP的虛擬主機(jī)比較 使用基于域名的虛擬主機(jī) 與舊版瀏覽器的兼容性 基于IP地址的虛擬主機(jī) 系統(tǒng)需求 如何配置Apache 設(shè)置多個(gè)守護(hù)進(jìn)程 配置擁有多個(gè)虛擬主機(jī)的單一守護(hù)進(jìn)程 動(dòng)態(tài)配置大量虛擬主機(jī) 動(dòng)機(jī) 概述 簡(jiǎn)單的動(dòng)態(tài)虛擬主機(jī) 一個(gè)實(shí)際的個(gè)人主頁(yè)系統(tǒng) 在同一個(gè)服務(wù)器上架設(shè)多個(gè)主機(jī)的虛擬系統(tǒng) 更為有效的基于IP地址的虛擬主機(jī) 使用老版本的Apache 使用mod_rewrite實(shí)現(xiàn)簡(jiǎn)單的動(dòng)態(tài)虛擬主機(jī) 使用mod_rewrite的個(gè)人主頁(yè)系統(tǒng) 使用獨(dú)立的虛擬主機(jī)配置文件 虛擬主機(jī)的普通配置示例 在一個(gè)IP地址上運(yùn)行多個(gè)基于域名的web站點(diǎn) 在多于一個(gè)IP的情況下使用基于域名的虛擬主機(jī) 在不同的IP的地址(比如一個(gè)內(nèi)部和一個(gè)外部地址)上提供相同的內(nèi)容 在不同的端口上運(yùn)行不同的站點(diǎn) 建立基于IP的虛擬主機(jī) 混用基于端口和基于IP的虛擬主機(jī) 混用基于域名和基于IP的虛擬主機(jī) 將虛擬主機(jī)和代理模塊一起使用 使用默認(rèn)虛擬主機(jī) 將一個(gè)基于域名的虛擬主機(jī)移植為一個(gè)基于IP的虛擬主機(jī) 使用ServerPath指令 深入討論虛擬主機(jī)的匹配 解析配置文件 虛擬主機(jī)匹配 小技巧 文件描述符限制 關(guān)于DNS和Apache 一個(gè)簡(jiǎn)單示例 拒絕服務(wù) "主服務(wù)器"地址 避免這些問(wèn)題的小技巧 附錄:進(jìn)一步的提示 常見(jiàn)問(wèn)題 概述 SSL/TLS 加密 概述 文檔 mod_ssl 緒論 密碼技術(shù) 證書(shū) 安全套接字層(SSL) 參考 兼容性 配置指令 環(huán)境變量 自定義日志功能 如何... 加密方案和強(qiáng)制性高等級(jí)安全 客戶認(rèn)證和訪問(wèn)控制 常見(jiàn)問(wèn)題解答 About The Module Installation Configuration Certificates The SSL Protocol mod_ssl Support 如何.../指南 概述 認(rèn)證 相關(guān)模塊和指令 簡(jiǎn)介 先決條件 啟用認(rèn)證 允許多人訪問(wèn) 可能存在的問(wèn)題 其他認(rèn)證方法 更多信息 CGI動(dòng)態(tài)頁(yè)面 簡(jiǎn)介 配置Apache以允許CGI 編寫(xiě)CGI程序 程序還是不能運(yùn)行! 幕后是怎樣操作的? CGI模塊/庫(kù) 更多信息 服務(wù)器端包含 簡(jiǎn)介 什么是SSI? 配置服務(wù)器以允許SSI 基本SSI指令 附加的例子 我還能設(shè)置其它什么? 執(zhí)行命令 高級(jí)SSI技術(shù) 總結(jié) .htaccess文件 .htaccess文件 工作原理和使用方法 (不)使用.htaccess文件的場(chǎng)合 指令的生效 認(rèn)證舉例 服務(wù)器端包含(SSI)舉例 CGI舉例 疑難解答 用戶網(wǎng)站目錄 用戶網(wǎng)站目錄 用UserDir設(shè)置文件路徑 限定哪些用戶可以使用此功能 啟用對(duì)每個(gè)用戶都有效的cgi目錄 允許用戶改變配置 對(duì)特定平臺(tái)的說(shuō)明 概述 Microsoft Windows 其他平臺(tái) 在Microsoft Windows中使用Apache 對(duì)操作系統(tǒng)的要求 下載 Apache for Windows 安裝 Apache for Windows 配置 Apache for Windows 以服務(wù)方式運(yùn)行 Apache for Windows 作為控制臺(tái)程序運(yùn)行Apache 測(cè)試安裝 編譯Windows下的Apache 系統(tǒng)要求 命令行編譯 Developer Studio集成開(kāi)發(fā)環(huán)境的工作區(qū)編譯 項(xiàng)目組件 在Novell NetWare平臺(tái)上使用Apache Requirements Downloading Apache for NetWare Installing Apache for NetWare Running Apache for NetWare Configuring Apache for NetWare Compiling Apache for NetWare 在HP-UX中運(yùn)行Apache The Apache EBCDIC Port Overview of the Apache EBCDIC Port Design Goals Technical Solution Porting Notes Document Storage Notes Apache Modules' Status Third Party Modules' Status 服務(wù)器與支持程序 概述 httpd 語(yǔ)法 選項(xiàng) ab 語(yǔ)法 選項(xiàng) Bugs apachectl 語(yǔ)法 選項(xiàng) apxs 語(yǔ)法 選項(xiàng) 舉例 configure 語(yǔ)法 選項(xiàng) 環(huán)境變量 dbmmanage 語(yǔ)法 選項(xiàng) Bugs htcacheclean 語(yǔ)法 選項(xiàng) 返回值 htdbm 語(yǔ)法 選項(xiàng) Bugs 返回值 舉例 安全方面的考慮 限制 htdigest 語(yǔ)法 選項(xiàng) htpasswd 語(yǔ)法 選項(xiàng) 返回值 舉例 安全方面的考慮 限制 logresolve 語(yǔ)法 選項(xiàng) rotatelogs 語(yǔ)法 選項(xiàng) Portability suexec 語(yǔ)法 選項(xiàng) 其他程序 log_server_status split-logfile 雜項(xiàng)文檔 概述 相關(guān)標(biāo)準(zhǔn) HTTP推薦標(biāo)準(zhǔn) HTML推薦標(biāo)準(zhǔn) 認(rèn)證 語(yǔ)言/國(guó)家代碼 Apache 模塊 描述模塊的術(shù)語(yǔ) 說(shuō)明 狀態(tài) 源代碼文件 模塊標(biāo)識(shí)符 兼容性 描述指令的術(shù)語(yǔ) 說(shuō)明 語(yǔ)法 默認(rèn)值(Default) 作用域(Context) 覆蓋項(xiàng)(Override) 狀態(tài) 模塊(Module) 兼容性(Compatibility) Apache核心(Core)特性 AcceptFilter AcceptPathInfo AccessFileName AddDefaultCharset AddOutputFilterByType AllowEncodedSlashes AllowOverride AuthName AuthType CGIMapExtension ContentDigest DefaultType <Directory> <DirectoryMatch> DocumentRoot EnableMMAP EnableSendfile ErrorDocument ErrorLog FileETag <Files> <FilesMatch> ForceType HostnameLookups <IfDefine> <IfModule> Include KeepAlive KeepAliveTimeout <Limit> <LimitExcept> LimitInternalRecursion LimitRequestBody LimitRequestFields LimitRequestFieldSize LimitRequestLine LimitXMLRequestBody <Location> <LocationMatch> LogLevel MaxKeepAliveRequests NameVirtualHost Options Require RLimitCPU RLimitMEM RLimitNPROC Satisfy ScriptInterpreterSource ServerAdmin ServerAlias ServerName ServerPath ServerRoot ServerSignature ServerTokens SetHandler SetInputFilter SetOutputFilter TimeOut TraceEnable UseCanonicalName UseCanonicalPhysicalPort <VirtualHost> Apache MPM 公共指令 AcceptMutex CoreDumpDirectory EnableExceptionHook GracefulShutdownTimeout Group Listen ListenBackLog LockFile MaxClients MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ServerLimit StartServers StartThreads ThreadLimit ThreadsPerChild ThreadStackSize User Apache MPM beos MaxRequestsPerThread CoreDumpDirectory Group Listen ListenBacklog MaxClients MaxMemFree MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize StartThreads User Apache MPM event AcceptMutex CoreDumpDirectory EnableExceptionHook Group Listen ListenBacklog LockFile MaxClients MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ScoreBoardFile SendBufferSize ServerLimit StartServers ThreadLimit ThreadsPerChild ThreadStackSize User Apache MPM netware MaxThreads Listen ListenBacklog MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads ReceiveBufferSize SendBufferSize StartThreads ThreadStackSize Apache MPM os2 Group Listen ListenBacklog MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize SendBufferSize StartServers User Apache MPM prefork 工作方式 MaxSpareServers MinSpareServers AcceptMutex CoreDumpDirectory EnableExceptionHook Group Listen ListenBacklog LockFile MaxClients MaxMemFree MaxRequestsPerChild PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ServerLimit StartServers User Apache MPM winnt Win32DisableAcceptEx CoreDumpDirectory Listen ListenBacklog MaxMemFree MaxRequestsPerChild PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ThreadLimit ThreadsPerChild ThreadStackSize Apache MPM worker 工作方式 AcceptMutex CoreDumpDirectory EnableExceptionHook Group Listen ListenBacklog LockFile MaxClients MaxMemFree MaxRequestsPerChild MaxSpareThreads MinSpareThreads PidFile ReceiveBufferSize ScoreBoardFile SendBufferSize ServerLimit StartServers ThreadLimit ThreadsPerChild ThreadStackSize User Apache Module mod_actions Action指令 Script指令 Apache Module mod_alias 處理順序 Alias AliasMatch Redirect RedirectMatch RedirectPermanent RedirectTemp ScriptAlias ScriptAliasMatch Apache Module mod_asis 用法 Apache Module mod_auth_basic AuthBasicAuthoritative AuthBasicProvider Apache Module mod_auth_digest 使用摘要認(rèn)證 配合 MS Internet Explorer 6 工作 AuthDigestAlgorithm AuthDigestDomain AuthDigestNcCheck AuthDigestNonceFormat AuthDigestNonceLifetime AuthDigestProvider AuthDigestQop AuthDigestShmemSize Apache Module mod_authn_alias 示例 <AuthnProviderAlias> Apache Module mod_authn_anon 示例 Anonymous Anonymous_LogEmail Anonymous_MustGiveEmail Anonymous_NoUserID Anonymous_VerifyEmail Apache Module mod_authn_dbd 配置示例 AuthDBDUserPWQuery AuthDBDUserRealmQuery Apache Module mod_authn_dbm AuthDBMType AuthDBMUserFile Apache Module mod_authn_default AuthDefaultAuthoritative Apache Module mod_authn_file AuthUserFile Apache Module mod_authnz_ldap Contents Operation The require Directives 舉例 Using TLS Using SSL Using Microsoft FrontPage with mod_authnz_ldap AuthLDAPBindDN AuthLDAPBindPassword AuthLDAPCharsetConfig AuthLDAPCompareDNOnServer AuthLDAPDereferenceAliases AuthLDAPGroupAttribute AuthLDAPGroupAttributeIsDN AuthLDAPRemoteUserIsDN AuthLDAPUrl AuthzLDAPAuthoritative Apache Module mod_authz_dbm AuthDBMGroupFile AuthzDBMAuthoritative AuthzDBMType Apache Module mod_authz_default AuthzDefaultAuthoritative Apache Module mod_authz_groupfile AuthGroupFile AuthzGroupFileAuthoritative Apache Module mod_authz_host Allow Deny Order Apache Module mod_authz_owner 配置示例 AuthzOwnerAuthoritative Apache Module mod_authz_user AuthzUserAuthoritative Apache Module mod_autoindex Autoindex Request Query Arguments AddAlt AddAltByEncoding AddAltByType AddDescription AddIcon AddIconByEncoding AddIconByType DefaultIcon HeaderName IndexIgnore IndexOptions IndexOrderDefault IndexStyleSheet ReadmeName Apache Module mod_cache Related Modules and Directives 配置示例 CacheDefaultExpire CacheDisable CacheEnable CacheIgnoreCacheControl CacheIgnoreHeaders CacheIgnoreNoLastMod CacheLastModifiedFactor CacheMaxExpire CacheStoreNoStore CacheStorePrivate Apache Module mod_cern_meta MetaDir MetaFiles MetaSuffix Apache Module mod_cgi CGI 環(huán)境變量 CGI 腳本的調(diào)試 ScriptLog ScriptLogBuffer ScriptLogLength Apache Module mod_cgid ScriptSock ScriptLog ScriptLogBuffer ScriptLogLength Apache Module mod_charset_lite Common Problems CharsetDefault CharsetOptions CharsetSourceEnc Apache Module mod_dav Enabling WebDAV Security Issues Complex Configurations Dav DavDepthInfinity DavMinTimeout Apache Module mod_dav_fs DavLockDB Apache Module mod_dav_lock DavGenericLockDB Apache Module mod_dbd Connection Pooling Apache DBD API SQL Prepared Statements DBDExptime DBDKeep DBDMax DBDMin DBDParams DBDPersist DBDPrepareSQL DBDriver Apache Module mod_deflate 配置舉例 啟用壓縮 代理服務(wù)器 DeflateBufferSize DeflateCompressionLevel DeflateFilterNote DeflateMemLevel DeflateWindowSize Apache Module mod_dir DirectoryIndex DirectorySlash Apache Module mod_disk_cache CacheDirLength CacheDirLevels CacheMaxFileSize CacheMinFileSize CacheRoot Apache Module mod_dumpio 啟用dumpio支持 DumpIOInput DumpIOOutput Apache Module mod_echo ProtocolEcho Apache Module mod_env PassEnv SetEnv UnsetEnv Apache Module mod_example Compiling the example module Using the mod_example Module Example Apache Module mod_expires 交替間隔語(yǔ)法 ExpiresActive ExpiresByType ExpiresDefault Apache Module mod_ext_filter 舉例 ExtFilterDefine ExtFilterOptions Apache Module mod_file_cache Using mod_file_cache CacheFile MMapFile Apache Module mod_filter Smart Filtering Filter Declarations Configuring the Chain Examples Protocol Handling FilterChain FilterDeclare FilterProtocol FilterProvider FilterTrace Apache Module mod_headers 處理順序 前處理和后處理 舉例 Header RequestHeader Apache Module mod_ident IdentityCheck IdentityCheckTimeout Apache Module mod_imagemap New Features Imagemap File Example Mapfile Referencing your mapfile ImapBase ImapDefault ImapMenu Apache Module mod_include Enabling Server-Side Includes PATH_INFO with Server Side Includes Basic Elements Include Variables Variable Substitution Flow Control Elements SSIEndTag SSIErrorMsg SSIStartTag SSITimeFormat SSIUndefinedEcho XBitHack Apache Module mod_info 安全問(wèn)題 選擇哪些信息可以被顯示 已知的局限 AddModuleInfo Apache Module mod_isapi 用法 附加注釋 程序員注記 ISAPIAppendLogToErrors ISAPIAppendLogToQuery ISAPICacheFile ISAPIFakeAsync ISAPILogNotSupported ISAPIReadAheadBuffer Apache Module mod_ldap 示例配置 LDAP 連接池 LDAP 緩沖 使用SSL/TLS SSL/TLS 證書(shū) LDAPCacheEntries LDAPCacheTTL LDAPConnectionTimeout LDAPOpCacheEntries LDAPOpCacheTTL LDAPSharedCacheFile LDAPSharedCacheSize LDAPTrustedClientCert LDAPTrustedGlobalCert LDAPTrustedMode LDAPVerifyServerCert Apache Module mod_log_config 定制日志文件格式 安全考慮 BufferedLogs CookieLog CustomLog LogFormat TransferLog Apache Module mod_log_forensic 定制日志文件格式 安全考慮 ForensicLog Apache Module mod_logio 定制日志文件格式 Apache Module mod_mem_cache MCacheMaxObjectCount MCacheMaxObjectSize MCacheMaxStreamingBuffer MCacheMinObjectSize MCacheRemovalAlgorithm MCacheSize Apache Module mod_mime 帶多擴(kuò)展名的文件 內(nèi)容編碼 字符集和語(yǔ)言 AddCharset AddEncoding AddHandler AddInputFilter AddLanguage AddOutputFilter AddType DefaultLanguage ModMimeUsePathInfo MultiviewsMatch RemoveCharset RemoveEncoding RemoveHandler RemoveInputFilter RemoveLanguage RemoveOutputFilter RemoveType TypesConfig Apache Module mod_mime_magic "Magic文件"的格式 性能問(wèn)題 注意 MimeMagicFile Apache Module mod_negotiation 類型表 MultiViews CacheNegotiatedDocs ForceLanguagePriority LanguagePriority Apache Module mod_nw_ssl NWSSLTrustedCerts NWSSLUpgradeable SecureListen Apache Module mod_proxy 正向和反向代理 簡(jiǎn)單示例 控制對(duì)代理服務(wù)器的訪問(wèn) 緩慢啟動(dòng) 局域網(wǎng)代理 協(xié)議調(diào)整 請(qǐng)求體 AllowCONNECT NoProxy <Proxy> ProxyBadHeader ProxyBlock ProxyDomain ProxyErrorOverride ProxyIOBufferSize <ProxyMatch> ProxyMaxForwards ProxyPass ProxyPassReverse ProxyPassReverseCookieDomain ProxyPassReverseCookiePath ProxyPreserveHost ProxyReceiveBufferSize ProxyRemote ProxyRemoteMatch ProxyRequests ProxyTimeout ProxyVia Apache Module mod_proxy_ajp Overview of the protocol Basic Packet Structure Request Packet Structure Response Packet Structure Apache Module mod_proxy_balancer Load balancer scheduler algorithm Request Counting Algorithm Weighted Traffic Counting Algorithm Enabling Balancer Manager Support Apache Module mod_proxy_connect Apache Module mod_proxy_ftp 為什么xxx類型的文件不能從FTP下載? 如何強(qiáng)制文件xxx使用FTP的ASCII形式下載? 我如何使用FTP上傳? 我如何能訪問(wèn)我自己home目錄以外的FTP文件? 我如何才能在瀏覽器的URL框中隱藏FTP的明文密碼? Apache Module mod_proxy_http Apache Module mod_rewrite 特殊字符的引用 環(huán)境變量 實(shí)用方案 RewriteBase RewriteCond RewriteEngine RewriteLock RewriteLog RewriteLogLevel RewriteMap RewriteOptions RewriteRule Apache Module mod_setenvif BrowserMatch BrowserMatchNoCase SetEnvIf SetEnvIfNoCase Apache Module mod_so 為Windows創(chuàng)建可加載模塊 LoadFile LoadModule Apache Module mod_speling CheckSpelling Apache Module mod_ssl 環(huán)境變量 Custom Log Formats SSLCACertificateFile SSLCACertificatePath SSLCADNRequestFile SSLCADNRequestPath SSLCARevocationFile SSLCARevocationPath SSLCertificateChainFile SSLCertificateFile SSLCertificateKeyFile SSLCipherSuite SSLCryptoDevice SSLEngine SSLHonorCipherOrder SSLMutex SSLOptions SSLPassPhraseDialog SSLProtocol SSLProxyCACertificateFile SSLProxyCACertificatePath SSLProxyCARevocationFile SSLProxyCARevocationPath SSLProxyCipherSuite SSLProxyEngine SSLProxyMachineCertificateFile SSLProxyMachineCertificatePath SSLProxyProtocol SSLProxyVerify SSLProxyVerifyDepth SSLRandomSeed SSLRequire SSLRequireSSL SSLSessionCache SSLSessionCacheTimeout SSLUserName SSLVerifyClient SSLVerifyDepth Apache Module mod_status Enabling Status Support 自動(dòng)更新 Machine Readable Status File ExtendedStatus Apache Module mod_suexec SuexecUserGroup Apache Module mod_unique_id Theory Apache Module mod_userdir UserDir Apache Module mod_usertrack Logging 2-digit or 4-digit dates for cookies? CookieDomain CookieExpires CookieName CookieStyle CookieTracking Apache Module mod_version <IfVersion> Apache Module mod_vhost_alias 目錄名稱的轉(zhuǎn)換 示例 VirtualDocumentRoot VirtualDocumentRootIP VirtualScriptAlias VirtualScriptAliasIP 開(kāi)發(fā)者文檔 Overview Topics External Resources Apache API notes Basic concepts How handlers work Resource allocation and resource pools Configuration Debugging Memory Allocation in APR Available debugging options Allowable Combinations Activating Debugging Options Documenting Apache 2.0 Apache 2.0 Hook Functions Creating a hook function Hooking the hook Converting Modules from Apache 1.3 to Apache 2.0 The easier changes ... The messier changes... Request Processing in Apache 2.0 The Request Processing Cycle The Request Parsing Phase The Security Phase The Preparation Phase The Handler Phase How Filters Work in Apache 2.0 Filter Types How are filters inserted? Asis Explanations 詞匯和索引 詞匯表 模塊索引 指令索引 指令速查 譯者聲明
文字

大批量虛擬主機(jī)的動(dòng)態(tài)配置

本文檔描述如何使用Apache有效的架設(shè)大批量虛擬主機(jī)。

動(dòng)機(jī)

如果你的配置文件httpd.conf中包含類似下面的許多<VirtualHost>段,并且其中的內(nèi)容都大致相同的話,你應(yīng)該會(huì)對(duì)這里所講的技術(shù)感興趣。比如:

NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44>
ServerName www.customer-1.com
DocumentRoot /www/hosts/www.customer-1.com/docs
ScriptAlias /cgi-bin/ /www/hosts/www.customer-1.com/cgi-bin
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName www.customer-2.com
DocumentRoot /www/hosts/www.customer-2.com/docs
ScriptAlias /cgi-bin/ /www/hosts/www.customer-2.com/cgi-bin
</VirtualHost>
# 等 等 等 。。。
<VirtualHost 111.22.33.44>
ServerName www.customer-N.com
DocumentRoot /www/hosts/www.customer-N.com/docs
ScriptAlias /cgi-bin/ /www/hosts/www.customer-N.com/cgi-bin
</VirtualHost>

最基本的思想是用動(dòng)態(tài)的機(jī)制來(lái)實(shí)現(xiàn)所有這些靜態(tài)的<VirtualHost>配置段。這樣做有許多優(yōu)點(diǎn):

  1. 配置文件變小,使得Apache可以更快的啟動(dòng),同時(shí)消耗更少的內(nèi)存。
  2. 添加一個(gè)虛擬主機(jī),應(yīng)該只是簡(jiǎn)單的在文件系統(tǒng)中創(chuàng)建合適的目錄,以及配置相關(guān)的DNS信息,且無(wú)需重新啟動(dòng)Apache 。

主要的缺點(diǎn)是你無(wú)法針對(duì)每個(gè)虛擬主機(jī)使用不同的日志文件。然而,如果真的在配置有大量虛擬主機(jī)的服務(wù)器上記錄不同的日志文件的話,很有可能會(huì)達(dá)到操作系統(tǒng)所允許的最大文件描述符的數(shù)量。更好的辦法是把日志寫(xiě)到管道或者先入先出的棧,并啟用其他的進(jìn)程來(lái)分揀所得到的日志信息(同時(shí)也可以做一些歷史紀(jì)錄的統(tǒng)計(jì)等等)。

概述

一個(gè)虛擬主機(jī)由兩部分來(lái)定義:一個(gè)是它的IP地址,還有一個(gè)是HTTP的"Host:"請(qǐng)求頭。動(dòng)態(tài)大量虛擬主機(jī)的技術(shù),是基于自動(dòng)在所要返回的文件路徑中插入相關(guān)信息的想法實(shí)現(xiàn)的。使用mod_vhost_alias可以很容易的實(shí)現(xiàn),但如果你的Apache版本低于1.3.6 ,則你必須使用mod_rewrite 。兩者在默認(rèn)情況下都不啟用;要使用他們,必須在配置和編譯Apache的階段啟用。

我們需要做很多"偽裝",才能使動(dòng)態(tài)虛擬主機(jī)看起來(lái)像普通主機(jī)。最重要的一點(diǎn)是Apache使用虛擬主機(jī)名(ServerName)來(lái)生成自引用(self-referential)URL等信息。這是用ServerName指令來(lái)配置的,并且可以通過(guò)環(huán)境變量SERVER_NAME傳遞給CGI腳本。運(yùn)行時(shí)實(shí)際使用的值是由UseCanonicalName指令的設(shè)置來(lái)控制的。當(dāng) UseCanonicalName Off 時(shí),虛擬主機(jī)名(ServerName)取自請(qǐng)求中的"Host:"頭。當(dāng) UseCanonicalName DNS 時(shí),則通過(guò)DNS反解析虛擬主機(jī)的IP地址得到主機(jī)名。以前的做法是基于名稱的動(dòng)態(tài)虛擬主機(jī),現(xiàn)在常用基于IP地址的虛擬主機(jī)。如果Apache無(wú)法判斷虛擬主機(jī)名,則可能是沒(méi)有"Host:"頭或是DNS解析失敗,這樣種情況下,Apache將使用配置ServerName時(shí)所填寫(xiě)的主機(jī)名。

另一件需要"偽裝"的事情是文檔根目錄(由DocumentRoot配置并可以通過(guò)DOCUMENT_ROOT環(huán)境變量為CGI腳本所使用)。在通常的配置方式下,這些設(shè)置信息由核心(core)模塊在將URI映射到文件系統(tǒng)的時(shí)候使用,但是如果使用動(dòng)態(tài)虛擬主機(jī)配置,這些信息將由另外一個(gè)使用不同于核心(core)模塊將URI映射到文件系統(tǒng)的方式的模塊(mod_vhost_aliasmod_rewrite)使用。這兩個(gè)模塊都不負(fù)責(zé)設(shè)置DOCUMENT_ROOT環(huán)境變量,所以如果CGI或SSI程序使用了DOCUMENT_ROOT環(huán)境變量,那么將得到錯(cuò)誤的值。

簡(jiǎn)單的動(dòng)態(tài)虛擬主機(jī)

這是httpd.conf文件中,完成和上文動(dòng)機(jī)部分所提到的虛擬主機(jī)一樣效果的配置方法,但這里采用了mod_vhost_alias模塊:

# 從"Host:"頭中取得主機(jī)名
UseCanonicalName Off

# 這種日志格式可以從第一個(gè)字段中提取出主機(jī)名
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

# 在返回請(qǐng)求的文件名路徑中包含主機(jī)名
VirtualDocumentRoot /www/hosts/%0/docs
VirtualScriptAlias /www/hosts/%0/cgi-bin

UseCanonicalName Off 的配置改為 UseCanonicalName DNS 即可實(shí)現(xiàn)基于IP地址的虛擬主機(jī)。而在文件路徑中所要插入的服務(wù)器名則通過(guò)虛擬主機(jī)的IP地址解析得到。

一個(gè)實(shí)際的個(gè)人主頁(yè)系統(tǒng)

這里對(duì)上面的系統(tǒng)作了一點(diǎn)調(diào)整,便可作為ISP的個(gè)人主頁(yè)服務(wù)器。我們使用了略微復(fù)雜的方法,從主機(jī)名(ServerName)中提取子字符串,并插入到文件路徑中。在這個(gè)例子中www.user.isp.com的文檔將在/home/user/中定位。并對(duì)所有虛擬主機(jī)使用單個(gè)cgi-bin目錄。

# 所有之前的準(zhǔn)備事項(xiàng)和上面一樣,然后在文件路徑中包含主機(jī)名
VirtualDocumentRoot /www/hosts/%2/docs

# 單個(gè)cgi-bin目錄
ScriptAlias /cgi-bin/ /www/std-cgi/

更復(fù)雜的關(guān)于VirtualDocumentRoot的設(shè)置,可以查閱mod_vhost_alias文檔。

在同一個(gè)服務(wù)器上架設(shè)多個(gè)主機(jī)的虛擬系統(tǒng)

更復(fù)雜的設(shè)置,應(yīng)該使用Apache的<VirtualHost>容器來(lái)管理各種虛擬主機(jī)配置的作用域。例如,你可以用一個(gè)IP地址來(lái)給個(gè)人主頁(yè)客戶使用,同時(shí)用下面的配置提供給商業(yè)客戶使用。自然的,這兩者通過(guò)運(yùn)用<VirtualHost>結(jié)合到一起。

UseCanonicalName Off

LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon

<Directory /www/commercial>
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory /www/homepages>
Options FollowSymLinks
AllowOverride None
</Directory>

<VirtualHost 111.22.33.44>
ServerName www.commercial.isp.com

CustomLog logs/access_log.commercial vcommon

VirtualDocumentRoot /www/commercial/%0/docs
VirtualScriptAlias /www/commercial/%0/cgi-bin
</VirtualHost>

<VirtualHost 111.22.33.45>
ServerName www.homepages.isp.com

CustomLog logs/access_log.homepages vcommon

VirtualDocumentRoot /www/homepages/%0/docs
ScriptAlias /cgi-bin/ /www/std-cgi/
</VirtualHost>

更為有效的基于IP地址的虛擬主機(jī)

在第一個(gè)例子中說(shuō)過(guò),轉(zhuǎn)為基于IP地址的虛擬主機(jī)設(shè)置很容易做到。但不幸的是,那種做法并不高效,因?yàn)檫@樣會(huì)在每次處理請(qǐng)求時(shí),需要查詢DNS。通過(guò)在文件系統(tǒng)中包含IP地址的做法可以避免這樣的問(wèn)題。這樣一來(lái),免去了和主機(jī)名的關(guān)聯(lián),在日志記錄中也一樣可以用IP來(lái)分離不同日志。Apache將不會(huì)為了確定主機(jī)名(ServerName)而去做DNS查詢。

# 從IP地址反解析得到主機(jī)名
UseCanonicalName DNS

# 在日志中包含IP地址,便于以后分揀
LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

# 在文件路徑中包含IP地址
VirtualDocumentRootIP /www/hosts/%0/docs
VirtualScriptAliasIP /www/hosts/%0/cgi-bin

使用老版本的Apache

上面的例子基于mod_vhost_alias ,但它是在版本1.3.6之后才出現(xiàn)的。如果你的版本比較老,可以通過(guò)使用mod_rewrite來(lái)達(dá)到相同的目的,如下所示。但只能是基于"Host:"頭方式的虛擬主機(jī)。

此外還須注意日志方面的問(wèn)題。Apache1.3.6是第一個(gè)支持"%V"日志格式指令的版本,在版本1.3.0-1.3.3中,"%v"選項(xiàng)做和"%V"一樣的事情;而在版本1.3.4中沒(méi)有等價(jià)指令。在所有的這些版本中,指令UseCanonicalName可以出現(xiàn)在.htaccess文件中,這意味著客戶的設(shè)置可能會(huì)導(dǎo)致日志記錄紊亂。所以最好的做法是使用"%{Host}i"指令,它可以直接記錄"Host:"頭;注意,這樣可能在末尾包含":port",而使用"%V"則不會(huì)這樣。

使用mod_rewrite實(shí)現(xiàn)簡(jiǎn)單的動(dòng)態(tài)虛擬主機(jī)

這里的例子摘自httpd.conf ,效果等同于第一個(gè)例子中的情況。前半部分和上面的例子大致相似,只是為了向后兼容mod_rewrite作了適當(dāng)修改;后半部分配置mod_rewrite來(lái)做實(shí)際的工作。

有些特別的地方需要注意:默認(rèn)情況下,mod_rewrite在所有其他URI轉(zhuǎn)換模塊(mod_alias等)之前運(yùn)行,所以如果使用這些模塊的話,mod_rewrite必須作相應(yīng)的調(diào)整。同時(shí),我們還要為每個(gè)動(dòng)態(tài)虛擬主機(jī)變些戲法,使之等效于ScriptAlias

# 從"Host:"頭獲取主機(jī)名
UseCanonicalName Off

# 可分揀的日志
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

<Directory /www/hosts>
# 這里需要ExecCGI ,因?yàn)槲覀儾荒軓?qiáng)制CGI以與ScriptAlias相同的方式執(zhí)行
Options FollowSymLinks ExecCGI
</Directory>

# 接下來(lái)是關(guān)鍵部分

RewriteEngine On

# 來(lái)自"Host:"頭的ServerName ,可能大小寫(xiě)混雜
RewriteMap lowercase int:tolower

## 首先處理普通文檔
# 允許變名/icons/起作用,其他變名類同
RewriteCond %{REQUEST_URI} !^/icons/
# 允許CGI
RewriteCond %{REQUEST_URI} !^/cgi-bin/
# 開(kāi)始"變戲法"
RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1

## 現(xiàn)在處理CGI(我們需要強(qiáng)制使用一個(gè)MIME類型)
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [T=application/x-httpd-cgi]

# ok 了!

使用mod_rewrite的個(gè)人主頁(yè)系統(tǒng)

這里的配置完成和第二個(gè)例子相同的工作。

RewriteEngine on

RewriteMap lowercase int:tolower

# 允許CGI工作
RewriteCond %{REQUEST_URI} !^/cgi-bin/

# 檢查hostname正確與否,之后才能使RewriteRule起作用
RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.[a-z-]+\.isp\.com$

# 將虛擬主機(jī)名字連接到URI的開(kāi)頭
# [C]表明本次重寫(xiě)的結(jié)果將在下一個(gè)rewrite規(guī)則中使用
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]

# 現(xiàn)在創(chuàng)建實(shí)際的文件名
RewriteRule ^www\.([a-z-]+)\.isp\.com/(.*) /home/$1/$2

# 定義全局CGI目錄
ScriptAlias /cgi-bin/ /www/std-cgi/

使用獨(dú)立的虛擬主機(jī)配置文件

這樣的布局利用了mod_rewrite的高級(jí)特性,在獨(dú)立的虛擬主機(jī)配置文件中轉(zhuǎn)換。如此可以更為靈活,但需要較為復(fù)雜的設(shè)置。

vhost.map文件包含了類似下面的內(nèi)容:

www.customer-1.com /www/customers/1
www.customer-2.com /www/customers/2
# ...
www.customer-N.com /www/customers/N

http.conf包含了:

RewriteEngine on

RewriteMap lowercase int:tolower

# 定義映射文件
RewriteMap vhost txt:/www/conf/vhost.map

# 和上面的例子一樣,處理別名
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
# 這里做基于文件的重新映射
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/docs/$1

RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1

上一篇: 下一篇: