📄 707-708.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=707-708//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="705-707.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch37/710-712.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>BindAddress</B></FONT></P>
<P>At startup, Apache binds to the port that it’s specified to bind to for all IP numbers that the box has available. The <TT>BindAddress</TT> directive can be used to specify only a specific IP address to bind to. By using this specific address, you can run multiple copies of Apache, each serving different virtual hosts, rather than have one daemon handle all virtual hosts. This is useful if you want to run two Web servers with different system user IDs, for security and access control reasons.</P>
<P>Suppose that you have three IP addresses: 1.1.1.1, 1.1.1.2, and 1.1.1.3, with 1.1.1.1 being the primary address for the machine. You want to run three Web servers, but you want one of them to run as a different user ID than the other two. You’d have two sets of configuration files. The first configuration file would say something like this:</P>
<!-- CODE SNIP //-->
<PRE>
User web3
BindAddress 1.1.1.3
ServerName www.company3.com
DocumentRoot /www/company3/
</PRE>
<!-- END CODE SNIP //-->
<P>The other configuration file would have the following:
</P>
<!-- CODE SNIP //-->
<PRE>
User web1
ServerName www.company1.com
DocumentRoot /www/company1/
<VirtualHost 1.1.1.2>
ServerName www.company2.com
DocumentRoot /www/company2/
</VirtualHost>
</PRE>
<!-- END CODE SNIP //-->
<P>If you launch the first, it will bind only to IP address 1.1.1.3. The second one, because it has no <TT>BindAddress</TT> directive, will bind to the port on all IP addresses. So you want to launch a server with the first set of configuration files, and then launch another copy of the server with the second set of configuration files. Two servers essentially would be running on the same machine.</P>
<P><FONT SIZE="+1"><B>PidFile</B></FONT></P>
<P><TT>PidFile</TT> is the location of the file containing the process ID for Apache. This file is useful for being able to automate the shutdown or restart of the Web server. By default, this parameter is logs/httpd.pid. For example, you could shut down the server with this command:</P>
<!-- CODE SNIP //-->
<PRE>
cat /usr/local/etc/httpd/logs/httpd.pid | xargs kill -15
</PRE>
<!-- END CODE SNIP //-->
<P>You might want to move this out of the logs directory and into a directory such as /var, but it’s not necessary.
</P>
<P><FONT SIZE="+1"><B>Timeout</B></FONT></P>
<P>The <TT>Timeout</TT> directive specifies the amount of time that the server will wait between packets sent before considering the connection “lost.” For example, 1200 (the default) means that the server will wait for 20 minutes after sending a packet before it considers the connection dead if no response comes back. Busy servers may want to shorten the time, at the cost of reduced service to low-bandwidth customers.</P>
<H3><A NAME="Heading22"></A><FONT COLOR="#000077">From Here…</FONT></H3>
<P>You can learn more about running the Apache Web server in the following chapters:
</P>
<DL>
<DD><B>•</B> Chapter 35, “Getting Started with Apache,” discusses the basics of installing and configuring the Apache Web server.
<DD><B>•</B> Chapter 37, “Managing an Internet Web Server,” shows you how to make your server robust, efficient, automated, and secure.
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="705-707.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch37/710-712.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 + -