841-843.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 156 行

HTML
156
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Configuring a WWW Site</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=51//-->

<!--PAGES=841-843//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="838-841.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="843-846.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>The <TT>AllowOverride</TT> variable is set to <TT>All</TT> by default and this should be changed. There are several valid values for <TT>AllowOverride</TT>, but the recommended setting for most Linux systems is <TT>None</TT>. The valid values for <TT>AllowOverride</TT> are as follows:</P>

<CENTER>

<TABLE WIDTH="80%"><TR>

<TD WIDTH="40%" VALIGN="TOP"><TT>All</TT>

<TD WIDTH="60%">Access controlled by a configuration file in each directory.

<TR>

<TD VALIGN="TOP"><TT>AuthConfig</TT>

<TD>Enables some authentication routines. Valid values: <TT>AuthName</TT> (sets authorization name of directory); <TT>AuthType</TT> (sets authorization type of the directory, although there is only one legal value: <TT>Basic</TT>); <TT>AuthUserFile</TT> (specifies a file containing usernames and passwords); and <TT>AuthGroupFile</TT> (specifies a file containing group names).

<TR>

<TD VALIGN="TOP"><TT>FileInfo</TT>

<TD>Enables <TT>AddType</TT> and <TT>AddEncoding</TT> directives.

<TR>

<TD><TT>Limit</TT>

<TD>Enables <TT>Limit</TT> directive.

<TR>

<TD><TT>None</TT>

<TD>No access files allowed.

<TR>

<TD><TT>Options</TT>

<TD>Enables <TT>Options</TT> directive.

</TABLE>

</CENTER>

<P>After all that, the configuration files should be properly set. While the syntax is a little confusing, reading the default values shows you the proper format to use when changing entries. Next, you can start the Web server software.

</P>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Starting the Web Software</FONT></H4>

<P>With the configuration complete, it&#146;s time to try out the Web server software. In the configuration files, you decided whether the Web software runs as a daemon (standalone) or starts from <TT>inetd</TT>. The startup procedure is a little different for each method (as you would expect), but both startup procedures can use one of the following three options on the command line:</P>

<CENTER>

<TABLE WIDTH="80%"><TR>

<TD WIDTH="30%" VALIGN="TOP"><TT>-d</TT>

<TD WIDTH="70%">The absolute path to the root directory of the server files (used only if the default location is not valid).

<TR>

<TD VALIGN="TOP"><TT>-f</TT>

<TD>The configuration file to read if not the default value of <TT>httpd.conf</TT>.

<TR>

<TD VALIGN="TOP"><TT>-v</TT>

<TD>Displays the version number.

</TABLE>

</CENTER>

<P>If you are using <TT>inetd</TT> to start your Web server software, you need to make a change to the <TT>/etc/services</TT> file to permit the Web software. Add a line similar to this to the <TT>/etc/services</TT> file:</P>

<!-- CODE SNIP //-->

<PRE>

http <I>port</I>/tcp

</PRE>

<!-- END CODE SNIP //-->

<P>where <I>port</I> is the port number used by your Web server software (usually 80).</P>

<P>Next, modify the <TT>/etc/inetd.conf</TT> file to include the startup commands for the Web server where the last entry is the path to the <TT>httpd</TT> binary:</P>

<!-- CODE SNIP //-->

<PRE>

httpd stream tcp nowait nobody /usr/web/httpd

</PRE>

<!-- END CODE SNIP //-->

<P>Once this is done, restart <TT>inetd</TT> by killing and restarting the <TT>inetd</TT> process or by rebooting your system, and the service should be available through whatever port you specified in <TT>/etc/services</TT>.</P>

<P>If you are running the Web server software as a daemon, you can start it at any time from the command line with the command:</P>

<!-- CODE SNIP //-->

<PRE>

httpd &#38;

</PRE>

<!-- END CODE SNIP //-->

<P>Even better, add the startup commands to the proper <TT>rc</TT> startup files. The entry usually looks like this:</P>

<!-- CODE SNIP //-->

<PRE>

# start httpd

if [ -x /usr/web/httpd ]

then

 /usr/web/httpd

fi

</PRE>

<!-- END CODE SNIP //-->

<P>substituting the proper paths for the <TT>httpd</TT> binary, of course. Rebooting your machine should start the Web server software on the default port number.</P>

<P>To test the Web server software, use any Web browser and enter the following in the URL field:</P>

<!-- CODE SNIP //-->

<PRE>

http://<I>machinename</I>

</PRE>

<!-- END CODE SNIP //-->

<P>where <I><TT>machinename</TT></I> is the name of your Web server. You can do this either over the Internet through a connection or from another machine on your network (if you have one). If you see the contents of the root Web directory or the <TT>index.html</TT> file, all is well. Otherwise, check the log files and configuration files for clues as to the problem.</P>

<P>If you haven&#146;t installed a Web browser yet, check to see if the Web server is running by using <TT>telnet</TT>. Issue a command like this, substituting the name of your server (and your Web port number if different than 80):</P>

<!-- CODE SNIP //-->

<PRE>

telnet www.wizard.tpci.com 80

</PRE>

<!-- END CODE SNIP //-->

<P>You should get a message similar to this if the Web server is responding properly:

</P>

<!-- CODE SNIP //-->

<PRE>

Connected to wizard.tpci.com

Escape character is &#146;^]&#146;.

HEAD/HTTP/1.0

HTTP/1.0 200 OK

</PRE>

<!-- END CODE SNIP //-->

<P>You&#146;ll also see some more lines showing details about the date and content. You may not be able to access anything, but this shows that the Web software is responding properly.

</P>

<H3><A NAME="Heading7"></A><FONT COLOR="#000077">Apache</FONT></H3>

<P>Apache is a Web server package that has become very popular lately. The reason for Apache&#146;s popularity is its ready availability for many platforms and its versatility. Apache was based on the Mosaic Web server mentioned earlier in this chapter, but with a considerable amount of new code added. Apache was written as public domain software and is available to anyone who wants it. There is a sizable support community on the Web and several books dedicated to the subject on your local bookshelves.

</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B><BR>As this book is being written the most current version of Apache is 1.2. There are many older versions available, but version 1.2 made many important changes to the software and is worth the effort to download if you don&#146;t have it. There is a Web site devoted to Apache at <A HREF="http://www.apache.org">http://www.apache.org</A>, and you can get code for the Apache Web server from most of the Linux FTP sites.<HR></FONT>

</BLOCKQUOTE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="838-841.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="843-846.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?