-->
Previous Table of Contents Next


PART VII
Setting Up a Linux Web Server

35  Getting Started with Apache
36  Configuring Apache
37  Managing an Internet Web Server

Chapter 35
Getting Started with Apache

by Steve Burnett

In this chapter
Compiling Apache
Establishing the File Hierarchy
Performing a Basic Configuration
Starting Up Apache
Debugging the Server Startup Process
Setting Up Apache-SSL

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.

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.

Compiling Apache

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.

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.

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:


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

Step 1: Edit the Configuration File

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.

You must declare which C compiler you’re using (most likely gcc), and you must uncomment the appropriate setting for AUX_CFLAGS. Just look down through the Makefile for the Linux entry for AUX_CFLAGS, which might look like this:


CC=gcc

AUX_CFLAGS = -DLINUX


NOTE:  For the CFLAGS definition, if you want every file with the execute bit set to be parsed for server-side includes, set -DXBITHACK. If you want to eliminate the overhead of performing the reverse-DNS lookup when an entry is written to the logfile, set -DMINIMAL_DNS.

See “Server-Side Includes,” p. 693

If, on the other hand, you want to have an even greater sense of confidence in the host name, you can set -DMAXIMAL_DNS. 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.


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.

Also, some modules, such as mod_auth_dbm, might require linking to an external library and need an entry added to the EXTRA_LIBS 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.

Step 2: Run the Configure Script

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.

Step 3: Run make

The make command compiles the server. You might see some warnings about data types, particularly if you compiled with -Wall set, but none of the errors should be fatal.

If all went well, you should now have an executable program in your src/ directory called httpd.


Previous Table of Contents Next