0153-0156.html

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

HTML
363
字号




<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Apache Server</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=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=09 //-->

<!-- PAGES=0153-0174 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="../ch08/0151-0152.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0157-0159.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-153"><P>Page 153</P></A>









<H3><A NAME="ch09_ 1">

CHAPTER 9

</A></H3>









<H2>



Apache Server



</H2>









<B>by Manuel Alberto Ricart, 

Eric Goebelbecker, and

Richard Bowen

</B>











<H3><A NAME="ch09_ 2">

IN THIS CHAPTER

</A></H3>









<UL>

<LI>     Server Installation 154

<LI>     Runtime Server Configuration Settings 155

<LI>     Configuring an inetd Server 159

<LI>     Running the Web Server for the First 

         Time 162

<LI>     Starting and Stopping the Server 163

<LI>     Configuration File Listings 165

</UL>





<A NAME="PAGENUM-154"><P>Page 154</P></A>











<P>This chapter guides you through the installation and configuration of the Apache Web

server using Red Hat's RPM system. Red Hat includes the current version of Apache with its

overall Linux product. However, if the latest version of Red Hat Linux is a few months old, a

more recent version of Apache can be found in the

/pub/contrib area of Red Hat's FTP server. For information about the latest version of Apache, such as what bug fixes and new features

have been added, see the Apache group's Web server,

<a href="http://www.apache.org">http://www.apache.org</A>, or the Apache Week Web site at

<a href="http://www.apacheweek.org.">http://www.apacheweek.org.</A>

</P>









<P>The current version of Red Hat Linux, version 4.2, includes Apache version 1.1.3. The

latest stable release of Apache available at the time of this printing is 1.2.4, and 1.3 is available

in beta form. Version 1.2.4 is available in RPM format on Red Hat's FTP server.

</P>









<P>There is a lag between the release of new and beta versions of Apache and its

corresponding RPM packages. Installing Apache from source code is possible on Red Hat Linux, but is

beyond the scope of this chapter because the installer has to either alter the directory structure

of the workstation or imitate the directory structure of a previous Apache

RPM.

</P>









<H3><A NAME="ch09_ 3">

Server Installation

</A></H3>









<P>The Apache RPM can either be found on the Red Hat Linux installation media or on the

Red Hat FTP server. It can be installed like any other RPM with the command-line

rpm tool or with glint, the X Window package management utility. To install the package using

rpm, execute

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -i latest_apache.rpm

</PRE>

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











<P>where latest_apache.rpm is the name of the latest Apache RPM.

</P>







<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

TIP

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

If Apache has already been installed on your system, this command will fail. To force

rpm to install the latest version, use this command:





<!-- CODE SNIP //-->

<PRE>

rpm -i --force apache-1.2.4-5.i386.rpm

</PRE>

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



</BLOCKQUOTE></TD></TR>

</TABLE>

</P>

<P>The Apache RPM installs files in the following directories:

</P>









<UL>

<LI>    /etc/httpd/conf&#151;This directory contains all the Apache configuration files.

<LI>    /etc/rc.d/&#151;The tree under this directory contains the system startup scripts.

The Apache RPM installs a complete set for the Web server. These scripts can be used

to start and stop the server from the command line and will also automatically start

and stop the server when the workstation is halted, started, or rebooted.

<LI>    /home/httpd&#151;The RPM installs the default server icons and CGI scripts in

this location.

</UL>





<A NAME="PAGENUM-155"><P>Page 155</P></A>











<UL>

<LI>     /usr/doc and /usr/man&#151;The RPM contains manual pages and

readme files, which are placed in these directories. As is the case for most RPM packages, the

readme and other related documentation is placed in a directory under

/usr/doc that is named for the server version.

<LI>

/usr/sbin&#151;The executable programs are placed in this

directory.

</UL>









<H3><A NAME="ch09_ 4">

Runtime Server Configuration Settings

</A></H3>









<P>Apache reads its configuration settings from three files:

access.conf, httpd.conf, and srm.conf. Primarily, this organization has been developed to maintain backward compatibility with

the NCSA server, but the reasoning behind it makes good sense. The configuration files reside

in the conf subdirectory of the server distribution. Backup copies of the configuration files

are included in the software distribution; they are named

access.conf-dist, httpd.conf-dist, and

srm.conf-dist, respectively.

</P>









<P>Runtime configuration of your server is done by way of

configuration directives. Directives are commands that set some option; you use them to tell the server about various options that

you want to enable, such as the location of files important to the server configuration and

operation. Configuration directives follow this syntax:

</P>





<!-- CODE SNIP //-->

<PRE>

directive option option...

</PRE>

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











<P>Directives are specified one per line. Some directives only set a value such as a filename;

others let you specify various options. Some special directives, called

sections, look like HTML tags. Section directives are surrounded by angle brackets, such as

&lt;directive&gt;. Sections usually enclose a group of directives that apply only to the directory specified in the section:

</P>





<!-- CODE SNIP //-->

<PRE>

&lt;Directory somedir/in/your/tree&gt;

  directive option option

  directive option option

&lt;/directive&gt;

</PRE>

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











<P>All sections are closed with a matching section tag that looks like

&lt;/directive&gt;. You will see some of these constructs in the

conf/access.conf and in your conf/httpd.conf files. Note

that section tags, like any other directives, are specified one

per line.

</P>









<H4><A NAME="ch09_ 5">





Editing httpd.conf

</A></H4>









<P>httpd.conf contains configuration directives that control how the server runs, where its

logfiles are found, the user ID (UID) it runs under, the port that it listens to, and so on. You need

to edit some of the default configuration values to settings that make sense in your site. I

kept most of the defaults found on my httpd.conf, with the exception of the following:

</P>



<BR>





<TABLE WIDTH="360">



<TR><TD>

ServerAdmin

</TD><TD>

The ServerAdmin directive should be set to the address

of the Webmaster managing the server. It should be a

valid e-mail address or alias, such as

webmaster@your.domain.

</TD></TR>

<BR>

<TR><TD>

</TD><TD>

Setting this value to a valid address is important

because this address will be returned to a visitor when a

problem occurs (see Figure 9.1).

</TD></TR>

</TABLE>





<A NAME="PAGENUM-156"><P>Page 156</P></A>



<BR>

Figure 9.1.<BR>

One of the error<BR> messages the server<BR> returns if an

error<BR> occurs. Note that the <BR>ServerAdmin was set to<BR>

alberto@accesslink.com.<BR>

<a href="08erhu02.html"><img src="images/tn_08erhu02_jpg.jpg"></a><BR>

<BR>





<TABLE WIDTH="360">



<TR><TD>

User and Group

</TD><TD>

The User and Group directives set the UID and group

ID (GID) that the server will use to process requests. I

kept these settings as the defaults: nobody and

nogroup. Verify that the names nobody and nogroup exist in your

/etc/passwd and /etc/group files, respectively. (They

are provided by Red Hat Linux, so they should already

be defined.) If you want to use a different UID or GID,

go ahead; however, be aware that the server will run

with the permissions you define here. The permissions for

the specified UID and GID should be limited because,

in case of a security hole, whether on the server or

(more likely) in your own CGI programs, those programs

will run with the assigned UID. If the server runs as root

or some other privileged user, someone can exploit

the security holes and do nasty things to your site. Instead

of specifying the User and Group directives using

names, you can specify them by using the UID and

GID numbers. If you use numbers, be sure that the

numbers

</TD></TR>

</TABLE>



<P><CENTER>

<a href="../ch08/0151-0152.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0157-0159.html">Next</A>

</CENTER></P>









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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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