846-848.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 134 行
HTML
134 行
<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=846-848//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="843-846.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch52/849-851.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">Editing the Configuration File</FONT></H4>
<P>Whether you compiled the Apache daemon <TT>httpd</TT> yourself or it was supplied ready-to-go with a Linux CD-ROM, you now have to set up the configuration file which is usually called <TT>httpd.conf</TT>. Under the Apache directory there should be a subdirectory called <TT>conf</TT>. Inside this directory should be three configuration files called <TT>srm.conf-dist</TT>, <TT>access.conf-dist</TT>, and <TT>httpd.conf-dist</TT>. These files have to be copied to new filenames using these commands:</P>
<!-- CODE SNIP //-->
<PRE>
cp srm.conf.-dist srm.conf
cp access.conf-dist access.conf
cp httpd.conf-dist httpd.conf
</PRE>
<!-- END CODE SNIP //-->
<P>Use any ASCII editor and open <TT>httpd.conf</TT>. The <TT>httpd.conf</TT> file contains general information about your server such as which port to use, the username to run as, and so on. Most of the information will be fine the way it is, but you can customize it if you want. Next, open <TT>srm.conf</TT> which is used to set up the document tree for the home pages as well as special HTML instructions. Again, most of the settings will be fine. Finally, the <TT>access.conf</TT> file is used to set the base levels of access to the system, and you can edit that to suit your needs or leave the default values.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>TIP: </B><BR>Apache supplies three configuration files by default but it doesn’t need to have three. In fact, it’s often easier to do just that for convenience in customizing and configuring Apache. If you do use a single file, the file <TT>httpd.conf</TT> is the one to use. To tell Apache to ignore the <TT>access.conf</TT> and <TT>srm.conf</TT> files and place these commands in the <TT>httpd.conf</TT> file:
<!-- CODE SNIP //-->
<PRE>
AccessConfig /dev/null
ResourceConfig /dev/null
Delete the two files access.conf and srm.conf from the directory.
</PRE>
<!-- END CODE SNIP //-->
<HR></FONT>
</BLOCKQUOTE>
<P>To start <TT>httpd</TT> with the configuration files you’ve prepared, use this command:</P>
<!-- CODE SNIP //-->
<PRE>
httpd -f path/httpd.conf
</PRE>
<!-- END CODE SNIP //-->
<P>The path above should be the full path to your <TT>httpd.conf</TT> file. The <TT>-f</TT> option tells <TT>httpd</TT> where to read the server configuration file. This will start the <TT>httpd</TT> server daemon, which you can verify with the <TT>ps</TT> command.</P>
<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">Apache httpd Command Flags</FONT></H4>
<P>You’ve seen one of the <TT>httpd</TT> command flags above. There are only a few flags involved with the <TT>httpd</TT> command. These are:</P>
<CENTER>
<TABLE WIDTH="80%"><TR>
<TD WIDTH="15%"><TT>-d</TT>
<TD WIDTH="85%">specifies the document root directory
<TR>
<TD><TT>-f</TT>
<TD>specifies the server configuration file
<TR>
<TD><TT>-h</TT>
<TD>lists directives in force (from the Configuration file)
<TR>
<TD><TT>-v</TT>
<TD>shows the version number
<TR>
<TD><TT>-X</TT>
<TD>for debugging
</TABLE>
</CENTER>
<P>A few other flags are added with each new release of Apache, but most are not used except for tweaking the system’s behavior or debugging. For a full list of flags, enter the command
</P>
<!-- CODE SNIP //-->
<PRE>
httpd -?
</PRE>
<!-- END CODE SNIP //-->
<P>Or check for a man page or the documentation available from the <TT>apache.org</TT> Web site under the <TT>/docs</TT> directory.</P>
<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">Setting Up Apache for a Simple Web Site</FONT></H4>
<P>To make things simple let’s assume you want to use Apache to act as the server for your local area network. Machines on your network will use a browser to log into the Apache server for Web pages. This simple example shows how to set up Apache for a straightforward network and can be modified slightly for a Web server to the Internet.
</P>
<P>We start by setting the root directory for the Web server. Let’s assume we’re setting up for a network called darkstar. The convention used by Apache is to call this <TT>site.darkstar</TT>. The configuration files for <TT>site.darkstar</TT> will be in a <TT>conf</TT> directory under the <TT>site.darkstar</TT> directory (such as <TT>/usr/web/site.darkstar/conf</TT>).</P>
<P>Set the document root directory for the site with the <TT>-d</TT> option of the <TT>httpd</TT> command:</P>
<!-- CODE SNIP //-->
<PRE>
httpd -d /usr/web/site.darkstar
</PRE>
<!-- END CODE SNIP //-->
<P>All of your documents for the Web site should reside in the documentation root directory and subdirectories. For this you’ll need HTML coding.
</P>
<P>There’s a lot more to Apache that lets you customize the server considerably but doing so is a little time-consuming and would take a hundred pages to explain. If you want to learn all there is to know about Apache, read the documents on the <TT>apache.org</TT> site or pick up one of the Apache books on the market.</P>
<H3><A NAME="Heading12"></A><FONT COLOR="#000077">Summary</FONT></H3>
<P>Setting up your home page requires you to either use an HTML authoring tool or write HTML code directly into an editor. The HTML language is beyond the scope of this book, but you should find several good guides to HTML at your bookstore. HTML is rather easy to learn. With the information in this chapter, you should be able to set up your Web site to enable anyone on the Internet to connect to you. Enjoy the Web!
</P>
<P>From here you can move to a number of different chapters depending on the type of information you are looking for. To learn about:</P>
<DL>
<DD>Writing CGI scripts for your Web page, see Chapter 52, “CGI Scripts.”
<DD>HTML, the language of Web home pages, see Chapter 53, “HTML Programming Basics.”
<DD>Java, which can be used to enhance the appearance and functionality of your Web pages, see Chapter 54, “Java and JavaScript Basics.”
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="843-846.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch52/849-851.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?