📄 683-686.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Configuring Apache</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=36//-->
<!--PAGES=683-686//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch35/699-673.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="686-688.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 36<BR>Configuring Apache
</FONT></H2>
<P><I>by Steve Burnett</I></P>
<DL>
<DT><B><BIG>I</BIG>n this chapter
</B><DT>Configuration Basics
<DT>Special Modules
<DT>Advanced Functionality
</DL>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Configuration Basics</FONT></H3>
<P>By now you should have a running Web server, although it will be minimally configured. In this chapter, you learn about most of the functionality that comes bundled with the server. This chapter is organized as a series of tutorials so that if you’re new to Apache, you can get up to speed quickly. Toward the end of the chapter, you dive into some experimental Apache modules as well.
</P>
<P>Because of its rapid pace of development, it’s possible that Apache will have some significantly new functionality by the time you read this chapter. However, the existing functionality isn’t likely to change much. The Apache Group has commitment to backward compatibility.</P>
<P>The srm.conf and access.conf files are where most of the configuration related to the actual objects on the server takes place. The srm.conf file is also known as the <TT>ResourceConfig</TT> file, which is a directive that can be set in httpd.conf; the access.conf file is also known as the <TT>AccessConfig</TT> file, which also is a directive in httpd.conf.</P>
<P>The names <I>srm.conf</I> and <I>access.conf</I> are mostly historical. At one point, when the server was still NCSA, the only thing access.conf was used for was setting permissions, restrictions, authentication, and so forth. Then, when directory indexing was added, the cry went out for the capability to control certain characteristics on a directory-by-directory basis. The access.conf file was the only configuration file that had any kind of structure for tight access control: the pseudo-HTML <TT><Directory></TT> container.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “access.conf,” <B>p. 677</B><HR></FONT>
</BLOCKQUOTE>
<P>With Apache’s configuration file-parsing routines, most directives can literally appear anywhere—for example, within <TT><Directory></TT> containers in access.conf, within <TT><VirtualHost></TT> containers in httpd.conf, and so on. However, for sanity’s sake, you should keep some structure to the configuration files. You should put server-processing-level configuration options (such as <TT>Port</TT> and <TT><VirtualHost></TT> containers) in httpd.conf, generic server resource information (such as <TT>Redirect</TT>, <TT>AddType</TT>, and directory indexing information) in srm.conf, and per-directory configurations in access.conf.</P>
<P>In addition to the <TT><Directory></TT> container is the <TT><Limit></TT> container, which is used within <TT><Directory></TT> containers to specify certain HTTP methods to which particular directives apply. Examples are given later in this chapter.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Although this chapter is still useful, release 1.3.0 and higher of Apache include a GNU Autoconf-style front-end, which supports all previous configuration options as well as the enhancements in 1.3.0 and above. Use of that interface for configuration is recommended in general.<HR></FONT>
</BLOCKQUOTE>
<H4 ALIGN="LEFT"><A NAME="Heading3"></A><FONT COLOR="#000077">Per-Directory Configuration Files</FONT></H4>
<P>Before you get too deep into the different configuration options, look at a mechanism that controls configuration on a directory-by-directory basis. This is accomplished by using a configuration file that’s local to the directory that you want to configure. You can already control subdirectory options in access.conf, as outlined in Chapter 35, “Getting Started with Apache.” However, for several reasons, you may want to allow these configurations to be maintained by users other than those with the power to restart the server (such as users maintaining their home pages). For that purpose the <TT>AccessFileName</TT> directive was invented.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “Performing a Basic Configuration,” <B>p. 674</B><HR></FONT>
</BLOCKQUOTE>
<P>The default <TT>AccessFileName</TT> is .htaccess. If you want to use something else—for example, .acc—you would say the following in the srm.conf file:</P>
<!-- CODE SNIP //-->
<PRE>
AccessFileName .acc
</PRE>
<!-- END CODE SNIP //-->
<P>If looking for the <TT>AccessFileName</TT> file is enabled and a request comes in that translates to the file /www/htdocs/path/path2/file, the server will look for /.acc, /www/.acc, /www/htdocs/.acc, /www/htdocs/path/.acc, and /www/htdocs/path/path2/.acc in that order. Also, if it finds the file, the server will parse the file to see what configuration options apply. (Remember that this parsing has to happen with each hit, separately, so this can be a big performance hit.) You can turn off the <TT>AccessFileName</TT> directive by setting the following options in your access config file:</P>
<!-- CODE SNIP //-->
<PRE>
<Directory />
AllowOverride None
</Directory>
</PRE>
<!-- END CODE SNIP //-->
<P>For the sake of brevity and clarity, assume that the <TT>AccessFileName</TT> option has set the name of these files to be .htaccess. What options can these files affect? The <TT>AllowOverride</TT> directive controls the range of available options within the <TT><Directory></TT> container in the <TT>AccessConfig</TT> file, as mentioned previously. Table 36.1 lists the exact arguments for <TT>AllowOverride</TT>.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 36.1</B> The <TT>AllowOverride</TT> Arguments
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="20%" ALIGN="LEFT">Argument
<TH WIDTH="80%" ALIGN="LEFT">Result
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TD VALIGN="TOP"><TT>AuthConfig</TT>
<TD>When listed, .htaccess files can specify their own authentication directives, such as <TT>AuthUserFile</TT>, <TT>AuthName</TT>, <TT>AuthType</TT>, and <TT>require</TT>.
<TR>
<TD VALIGN="TOP"><TT>FileInfo</TT>
<TD>When listed, .htaccess can override any settings for meta-information about files by using directives such as <TT>AddType</TT>, <TT>AddEncoding</TT>, and <TT>AddLanguage</TT>.
<TR>
<TD VALIGN="TOP"><TT>Indexes</TT>
<TD>When listed, .htaccess files can locally set directives that control the rendering of the directory indexing, as implemented in the mod_dir.c module—for example, <TT>FancyIndexing</TT>, <TT>AddIcon</TT>, and <TT>AddDescription</TT>.
<TR>
<TD VALIGN="TOP"><TT>Limit</TT>
<TD>This argument allows the use of the directives that limit access based on host name or host IP number (<TT>allow</TT>, <TT>deny</TT>, and <TT>order</TT>).
<TR>
<TD><TT>Options</TT>
<TD>This argument allows the use of the <TT>Options</TT> directive.
<TR>
<TD><TT>All</TT>
<TD>This argument allows all of the preceding arguments to be true.
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P><TT>AllowOverride</TT>options aren’t merged, meaning that if the configuration for /path/ is different than the configuration for /, the /path/ one will take precedence because it’s deeper.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch35/699-673.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="686-688.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -