📄 699-673.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Getting Started with 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=35//-->
<!--PAGES=699-673//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="680-682.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch36/683-686.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2 ALIGN="CENTER"><FONT COLOR="#000077"><I>PART VII<BR>Setting Up a Linux Web Server
</I></FONT></H2>
<DL>
<DT>35 Getting Started with Apache
<DT>36 Configuring Apache
<DT>37 Managing an Internet Web Server
</DL>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 35<BR>Getting Started with Apache
</FONT></H2>
<P><I>by Steve Burnett</I></P>
<DL>
<DT><B>In this chapter</B>
<DT>Compiling Apache
<DT>Establishing the File Hierarchy
<DT>Performing a Basic Configuration
<DT>Starting Up Apache
<DT>Debugging the Server Startup Process
<DT>Setting Up Apache-SSL
</DL>
<P>To use a Linux system as a Web server, you must install special server software on your system. Two of the most popular UNIX Web server packages are Apache and NCSA. In fact, a June 1998 survey showed that Apache accounted for more than 53 percent of all installed Web servers. Although this chapter, like several others, is specific to the Apache server, the vocabulary is certainly applicable to other Web servers. The NCSA family of servers has much in common with Apache with respect to configuration files, because Apache was derived originally from the NCSA 1.3 server, and maintaining backward compatibility with existing NCSA servers was a mandate with the development team.
</P>
<P>This chapter deals with all the essential steps needed to install the software and bring up a running, breathing, living server. If you’ve installed an Apache or NCSA server before, you can probably safely skip this chapter, although you should skim it to look for essential differences.</P>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Compiling Apache</FONT></H3>
<P>Apache is known to compile on just about every UNIX variant: Solaris 2.X, SunOS 4.1.X, Irix 5.X and 6.X, Linux, FreeBSD/NetBSD/BSDI, HP-UX, AIX, Ultrix, OSF1, NeXT, Sequent, A/UX, SCO, UTS, Apollo Domain/OS, QNX, and probably a few you’ve never even tried yet. A port to OS/2 has been done, and a beta Windows NT 4.0 port has been completed as of this writing. Portability has been a high priority for the development team.
</P>
<P>Apache binaries and their sources are included with most distributions of Linux. The complete source code for Apache is also provided. Because there are Apache binaries on the CD-ROMs, you can skip the compilation process and move on to the next section, if you’re in a hurry to get Apache up and running. However, if you ever want to add new modules or tweak the functionality provided by Apache, you need to know how to compile it.</P>
<P>Copy the source code package to a part of your file system. You need several spare megabytes of disk to compile the server. Unpack it and go to the /src subdirectory. A sequence of commands to do this might look like the following:</P>
<!-- CODE SNIP //-->
<PRE>
cd /CDROM
cp apache_1.3.0.tar.gz /usr/local/apache/
cd /usr/local/apache/
tar -zxvf apache_1.3.0.tar
cd src
</PRE>
<!-- END CODE SNIP //-->
<H4 ALIGN="LEFT"><A NAME="Heading3"></A><FONT COLOR="#000077">Step 1: Edit the Configuration File</FONT></H4>
<P>The Configuration file is used by the Configure program to create a Makefile specifically targeted to your platform, with any runtime defines set, if necessary, and with the modules you’ve chosen compiled together. It also creates a modules.c, which contains information about which modules to link together at compilation time.
</P>
<P>You must declare which C compiler you’re using (most likely <TT>gcc</TT>), and you must uncomment the appropriate setting for <TT>AUX_CFLAGS</TT>. Just look down through the Makefile for the Linux entry for <TT>AUX_CFLAGS</TT>, which might look like this:</P>
<!-- CODE SNIP //-->
<PRE>
CC=gcc
AUX_CFLAGS = -DLINUX
</PRE>
<!-- END CODE SNIP //-->
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>For the <TT>CFLAGS</TT> definition, if you want every file with the execute bit set to be parsed for server-side includes, set <TT>-DXBITHACK</TT>. If you want to eliminate the overhead of performing the reverse-DNS lookup when an entry is written to the logfile, set <TT>-DMINIMAL_DNS</TT>.
<P>• <B>See</B> “Server-Side Includes,” <B>p. 693</B></P>
<P>If, on the other hand, you want to have an even greater sense of confidence in the host name, you can set <TT>-DMAXIMAL_DNS</TT>. You would set this if you were protecting parts of your site based on host name. Doing this is optional and is provided mostly for backward compatibility with NCSA 1.3.<HR></FONT>
</BLOCKQUOTE>
</P>
<P>At the bottom of the file is a list of packaged modules that come with the Apache distribution. Notice that not all of them are compiled into the final program by default. To include a module in the build, uncomment the entry for it. Notice that some modules are mutually exclusive. For example, it wouldn’t be wise to compile the configurable logging module and the common logging module at the same time.</P>
<P>Also, some modules, such as <TT>mod_auth_dbm</TT>, might require linking to an external library and need an entry added to the <TT>EXTRA_LIBS</TT> line. You learn more about modules in a little bit; for the purposes of getting up and running, I recommend simply using the defaults as provided.</P>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Step 2: Run the Configure Script</FONT></H4>
<P>The configure script is a simple Bourne shell script that takes the configuration file and creates a Makefile out of it, as well as modules.c.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Step 3: Run <I>make</I>
</FONT></H4>
<P>The <TT>make</TT> command compiles the server. You might see some warnings about data types, particularly if you compiled with <TT>-Wall</TT> set, but none of the errors should be fatal.</P>
<P>If all went well, you should now have an executable program in your src/ directory called <TT>httpd</TT>.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="680-682.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch36/683-686.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 + -