Installation of Apache
IN THIS CHAPTER
- Introduction
- Compiling Apache
- Installing Apache on Unix
- Dynamic Shared Objects
- Binary Distributions
- Windows Installations
- Commercial Distributions
- Recap
Here's how I got started with Apache. Several years ago I was employed as a Web designer at a small company (which my attorney has advised me to leave nameless). One morning my boss, a guy named Bob, rapped on the side of my cubicle. Bob was some sort of sales creaturehe had a fine wardrobe and a haircut that was almost congressional, but he possessed no discernable technical skills. Of course, at the time I myself was far from a Web whiz
"Do you know anything about Apache?" Bob asked. "Was that Chief Joseph?" "Chief Joseph was Nez Percé." "Wounded knee?"
"Nope. The Web server."
"'Fraid not," I said, and turned back to the screen. At this time, the http protocol was still in its childhood. As I recall, I was trying to figure out how to pass the contents of a three-page order form to my machine through a single environment variable.
"That's a shame," Bob said. "How so?" "You're our new Webmaster." "Eh?" "Yup. Sridhar retired." "Sridhar retired? When?" "Yesterday."
"He can't be retired. He's barely old enough to drink."
"Actually, he isn't old enough to drink. He isn't even old enough to vote." Bob sighed. "Remember that stock he was telling us about a couple weeks ago?" "It took off?" "Big time. Sridhar left yesterday afternoon. The chauffeur said he was going yacht shopping. Did you buy any?" "No, I've been pouring all my investment cash into options for this company." "That's very loyal of you." "I suppose so." "Do you know anything about short selling?" I shook my head.
"Well, then, I suggest you start learning Apache."
Fortunately Apache server administration turned out to be considerably less painful than I first imagined. The first step is to get a working installation. It was easy even back then; in the years since, the process has been refined to the point where it is positively trivial. I think you'll find it an interesting and entertaining experience. Welcome.
Introduction
This chapter describes the process of obtaining and installing the Apache Web server on your system. In all likelihood, this will be a smooth and painless process, even if you are not a skilled programmer. At this writing, Apache has been downloaded hundreds of thousands of times. Most of the egregious bugs in the installation process have been worked out.
Depending on your level of expertise, you can exercise a great deal of control over the content and behavior of your Web server, up to and including wholesale modification of the source code. But if you want to keep things quick and simple, there are only three questions you need to answer:
What hardware and operating system platform will you install Apache on?
Do you want to install a source code or a binary distribution?
Where do you want to put the software?
Operating System
Distributions of Apache are available for almost all operating systems, including Linux, Windows, Mac OS X,1 and most of the commercial Unix distributions. In the absence of a pressing reason to do otherwise, you will be best served by installing Apache on one of the flavors of Unix. Let me stress here that the ported versions are fully functional and will work well. However, Apache was originally designed for a Unix/Linux environment, and most of the new development takes place on Unix first and trickles down to the rest of the world later.
Also, as you become more familiar with the directives, you will notice that many of them are predicated on the assumption that they are being run in a Unix environment. For example, both Windows and Unix versions of Apache have a single process serving as a parent. In a Unix environment, the parent process handles client requests by forking off a single copy of itself for each client it is serving. In Windows, the parent process has only a single child, which uses threads to service all client requests. This means that the MaxSpareServers and MinSpareServers (to name only two) are more or less meaningless in a Windows environment. This is not necessarily a bad thing, but you should be aware of it.
Source Code versus Binary Distributions
Apache is available in both source code and binary distributions. A source code distribution is a collection of the original source code files from which the Apache executable and associated modules are compiled. Source code distributions include scripts that can be used to compile the files into an executable program that can be used on your system.
The process of compiling usually is quick and painless, and it has many side benefits. When you compile your own executable program, you are able to exercise great control over which modules are included and, more significantly, which are left out. Recall that Apache forks off copies of itself to service client requests. If the individual copies are fat and bloated, they will quickly choke system performance.
Alternatively, binary distributions are available for most hardware platforms and operating systems. A binary distribution is a precompiled executable containing a default set of modules. This is the distribution that most closely resembles commercial software. If you are new to software development and nervous about compiling your own code, binary distributions probably will be your first choice. As of Apache 1.3.12, Apache binary distributions come with all standard Apache modules compiled as shared objects. This feature enables you to dynamically disable modules you are not using, thereby shrinking the size of the executable and improving performance.
Obtaining Apache
Regardless of the platform and distribution type you settle on, you will be obtaining them from the following URL:
http://www.apache.org/dist
The downloads you find in that directory are all of the source code variety. If you are interested in binaries you can either follow the link or go directly to the following URL:
http://www.apache.org/dist/binaries
To simplify and speed transmission, the source code distributions have been combined into a single downloadable file, and that file has been shrunk with one or another of the various compression utilities. On Unix, you will need to both uncompress and unpack the distribution before it is usable. Win32 distributions come as a self-unpacking file; all you need to do is double-click.
TIP
You may want to create a separate Unix filesystem to contain the Apache executables and, later, the servable Web documents. Providing a location in the directory tree where Apache can be segregated from the rest of the operating system is a good idea for both security and organizational purposes.
Unpacking the Distributions
UNPACKING UNIX DISTRIBUTIONS
The first step is to move the distribution file you downloaded into either its own filesystem or some location in the Unix hierarchy that is intended to contain third-party software and is large enough to contain the unpacked source code files. Currently you can get by with about 12 megabytes.
mv apache_X.Y.Z.tar.Z /apache
Next you can begin the process of extracting files from the archive:
tar -xvzf apache_X.Y.Z.tar.Z
WINDOWS
On Windows NT, you should first ensure that you have Service Pack 3 or better. Beyond that, installation on all Win32 platforms is just a matter of double clicking on the downloaded file.