📄 core.html.en
字号:
path from the requested URL to the document root to make the path to the document. Example:</p> <div class="example"><p><code> DocumentRoot /usr/web </code></p></div> <p>then an access to <code>http://www.my.host.com/index.html</code> refers to <code>/usr/web/index.html</code>. If the <var>directory-path</var> is not absolute then it is assumed to be relative to the <code class="directive"><a href="#serverroot">ServerRoot</a></code>.</p> <p>The <code class="directive">DocumentRoot</code> should be specified without a trailing slash.</p><h3>See also</h3><ul><li><a href="../urlmapping.html#documentroot">Mapping URLs to FilesystemLocations</a></li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="EnableMMAP" id="EnableMMAP">EnableMMAP</a> <a name="enablemmap" id="enablemmap">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Use memory-mapping to read files during delivery</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>EnableMMAP On|Off</code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>EnableMMAP On</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr></table> <p>This directive controls whether the <code class="program"><a href="../programs/httpd.html">httpd</a></code> may use memory-mapping if it needs to read the contents of a file during delivery. By default, when the handling of a request requires access to the data within a file -- for example, when delivering a server-parsed file using <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> -- Apache memory-maps the file if the OS supports it.</p> <p>This memory-mapping sometimes yields a performance improvement. But in some environments, it is better to disable the memory-mapping to prevent operational problems:</p> <ul> <li>On some multiprocessor systems, memory-mapping can reduce the performance of the <code class="program"><a href="../programs/httpd.html">httpd</a></code>.</li> <li>With an NFS-mounted <code class="directive"><a href="#documentroot">DocumentRoot</a></code>, the <code class="program"><a href="../programs/httpd.html">httpd</a></code> may crash due to a segmentation fault if a file is deleted or truncated while the <code class="program"><a href="../programs/httpd.html">httpd</a></code> has it memory-mapped.</li> </ul> <p>For server configurations that are vulnerable to these problems, you should disable memory-mapping of delivered files by specifying:</p> <div class="example"><p><code> EnableMMAP Off </code></p></div> <p>For NFS mounted files, this feature may be disabled explicitly for the offending files by specifying:</p> <div class="example"><p><code> <Directory "/path-to-nfs-files"> <span class="indent"> EnableMMAP Off </span> </Directory> </code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="EnableSendfile" id="EnableSendfile">EnableSendfile</a> <a name="enablesendfile" id="enablesendfile">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Use the kernel sendfile support to deliver files to the client</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>EnableSendfile On|Off</code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>EnableSendfile On</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr><tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.44 and later</td></tr></table> <p>This directive controls whether <code class="program"><a href="../programs/httpd.html">httpd</a></code> may use the sendfile support from the kernel to transmit file contents to the client. By default, when the handling of a request requires no access to the data within a file -- for example, when delivering a static file -- Apache uses sendfile to deliver the file contents without ever reading the file if the OS supports it.</p> <p>This sendfile mechanism avoids separate read and send operations, and buffer allocations. But on some platforms or within some filesystems, it is better to disable this feature to avoid operational problems:</p> <ul> <li>Some platforms may have broken sendfile support that the build system did not detect, especially if the binaries were built on another box and moved to such a machine with broken sendfile support.</li> <li>On Linux the use of sendfile triggers TCP-checksum offloading bugs on certain networking cards when using IPv6.</li> <li>On Linux on Itanium, sendfile may be unable to handle files over 2GB in size.</li> <li>With a network-mounted <code class="directive"><a href="#documentroot">DocumentRoot</a></code> (e.g., NFS or SMB), the kernel may be unable to serve the network file through its own cache.</li> </ul> <p>For server configurations that are vulnerable to these problems, you should disable this feature by specifying:</p> <div class="example"><p><code> EnableSendfile Off </code></p></div> <p>For NFS or SMB mounted files, this feature may be disabled explicitly for the offending files by specifying:</p> <div class="example"><p><code> <Directory "/path-to-nfs-files"> <span class="indent"> EnableSendfile Off </span> </Directory> </code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="ErrorDocument" id="ErrorDocument">ErrorDocument</a> <a name="errordocument" id="errordocument">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>What the server will return to the clientin case of an error</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ErrorDocument <var>error-code</var> <var>document</var></code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr><tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Quoting syntax for text messages is different in Apache2.0</td></tr></table> <p>In the event of a problem or error, Apache can be configured to do one of four things,</p> <ol> <li>output a simple hardcoded error message</li> <li>output a customized message</li> <li>redirect to a local <var>URL-path</var> to handle the problem/error</li> <li>redirect to an external <var>URL</var> to handle the problem/error</li> </ol> <p>The first option is the default, while options 2-4 are configured using the <code class="directive">ErrorDocument</code> directive, which is followed by the HTTP response code and a URL or a message. Apache will sometimes offer additional information regarding the problem/error.</p> <p>URLs can begin with a slash (/) for local web-paths (relative to the <code class="directive"><a href="#documentroot">DocumentRoot</a></code>), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser. Examples:</p> <div class="example"><p><code> ErrorDocument 500 http://foo.example.com/cgi-bin/tester<br /> ErrorDocument 404 /cgi-bin/bad_urls.pl<br /> ErrorDocument 401 /subscription_info.html<br /> ErrorDocument 403 "Sorry can't allow you access today" </code></p></div> <p>Additionally, the special value <code>default</code> can be used to specify Apache's simple hardcoded message. While not required under normal circumstances, <code>default</code> will restore Apache's simple hardcoded message for configurations that would otherwise inherit an existing <code class="directive">ErrorDocument</code>.</p> <div class="example"><p><code> ErrorDocument 404 /cgi-bin/bad_urls.pl<br /><br /> <Directory /web/docs><br /> <span class="indent"> ErrorDocument 404 default<br /> </span> </Directory> </code></p></div> <p>Note that when you specify an <code class="directive">ErrorDocument</code> that points to a remote URL (ie. anything with a method such as <code>http</code> in front of it), Apache will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code. In addition, if you use a remote URL in an <code>ErrorDocument 401</code>, the client will not know to prompt the user for a password since it will not receive the 401 status code. Therefore, <strong>if you use an <code>ErrorDocument 401</code> directive then it must refer to a local document.</strong></p> <p>Microsoft Internet Explorer (MSIE) will by default ignore server-generated error messages when they are "too small" and substitute its own "friendly" error messages. The size threshold varies depending on the type of error, but in general, if you make your error document greater than 512 bytes, then MSIE will show the server-generated error rather than masking it. More information is available in Microsoft Knowledge Base article <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q294807">Q294807</a>.</p> <p>Although most error messages can be overriden, there are certain circumstances where the internal messages are used regardless of the setting of <code class="directive"><a href="#errordocument">ErrorDocument</a></code>. In
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -