Apache Guide: The Newbie's Guide to Installing Apache

Monday Jul 3rd 2000 by Rich Bowen
Share:

Are you a true Apache newbie, with literally no experience at installing and configuring Apache? Fear not: Rich Bowen is here to guide you through the process.

In this week's article, I'll take you through installing an Apache server. I'm assuming you've never done this before, but that you know a few things about your operating system.

If you're beyond this stage, come back in a few weeks, as we'll move on to more advanced things from here.


Acquiring Apache

Apache is free software. That is, it is Open Source, and can be downloaded, and redistributed, without any cost. You can read the full text of the Apache license (it's very short) on the Apache web site at http://www.apache.org/LICENSE.txt. But basically what it says is that you are free to use the product, as well as to redistribute it, without charge.

You can download Apache from the Apache Server web site, at http://www.apache.org/httpd.html There you'll find the Apache source code, as well as binary (precompiled) distributions for a large number of platforms.


Build it yourself

Unless there is some overwhelming reason not to do so, you really should get the source code and compile it yourself. There are a number of reasons for this.

  • Get the right combination of modules. When you install a binary distribution, that means that someone else compiled it, and made a decision on what modules to build into that binary distribution. They tried to make what seemed like the more reasonable choice, for the purposes of making the distribition usable by as many people as possible. This will invariably mean that there will be some modules in it that you really don't want, and there might be some left out that you would like to have.

  • Get is exactly right for your system. You may have something strange set up on your system that does not match the system of the individual that built the binary distribution. Perhaps a different version of some important libraries, Perhaps a newer version of some file that was used in the build process. And this may cause some problems when you try to use the file on your system.

  • The right file locations. Some binary distributions put files in very strange places. A notable culprit here is Red Hat. The RPM (Redhat Package Manager) installation of Apache puts files all over the place in the most obscure places. Of course, that's just my opinion. Apparently it made sense to somebody, because they keep doing it. Anyway, if you expect files to be in some reasonable place, and expect to be ablet to find them when you need them, don't install with the Red Hat RPM.

  • The right configuration. When you install the file yourself, it will end up with the configuration file that you expect. Binary distributions might have default configuration settings that are unexpected.

By building yourself from the source code, you'll make sure you have the Apache server that is right for you, rather than something that someone else thought might be best for you.


Quick form (guide for the impatient)

If you look at the file INSTALL, after unpacking the .tar.gz file that you downloaded, you will find the following instructions:


  1. Overview for the impatient
     --------------------------

     $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start

     NOTE: PREFIX is not the string "PREFIX". Instead use the Unix
           filesystem path under which Apache should be installed. For
           instance use "/usr/local/apache" for PREFIX above.

You'll find that the Apache documentation is very complete, and very helpful, if you know where to look. Following the above instructions will give you a usable installation of Apache to get you started, and this is probably the way that you want to install it the first time.

For example, if you wanted to install Apache in /home/httpd (not that you would, but if you did ...) you would type:

        ./configure --prefix=/home/httpd
        make
        make install
        /home/httpd/bin/apachectl start

configure will tell you that it is creating some makefiles. Both make and make install produce a great deal of output, describing what they are doing to build Apache. And at the end of the process, you will see a short message from the Apache Software Foundation thanking you for using Apache server.


Longer form - using configure

The command above - configure - takes a look at your system, and figures out how things are set up, so that it knows how the compilation process will need to be done. This ranges from figuring out how long a long integer is on your particular system to determining what compiler you are using.

As you saw in the above example, you can pass certain parameters to configure to influence the way that it will install Apache. For a complete list of what parameters you can specify, you should again see the file INSTALL, located in the top directory of wherever you unpacked the tar file. For a more indepth discussion of using configure, see the file README.configure


Enabling DSO support

One configure trick that is worth mentioning specially is enabling DSO support. DSOs (Dynamic Shared Objects) are a way to compile Apache modules (and other things) so that they can be loaded into the server at run time, rather than building them directly into the Apache executable. This lets you decide to load, or not load, particular modules, without having to recompile Apache.

To build Apache with DSO support, and make most of the available Apache modules ready to use, type the following command:


        ./configure --prefix=/path/to/apache                 --enable-module=most                 --enable-shared=max

(Note: You can type that all on one line. The \ indicates that the command line is continued on the next line. This syntax is supported on most Unix operating systems.)

In this case ''most'' means all of the modules that are shipped with Apache, leaving out those that are considered experimental, or which don't run on all platforms.

You will then need to enable, or disable, various module, by uncommenting, or commenting out, LoadModule lines in httpd.conf - the main Apache configuration file.


mod_perl, mod_php, and other stuff

README.configure contains instructions for configuring a lot of other useful things too, such as mod_perl and mod_php. These are modules that are not included in the Apache distribution, and so you will need to download separately.


Really long form - using Configure

Using configure to configure the Apache installation is the new way to do things. It makes life a lot easier, and lets someone with a little less experience get a server running without having to peer into the Apache source code. The ''old-fashioned'' way to do things is with the Configure script. That's Configure with a big C, as opposed to configure with a small c. Configure is located in the src subdirectory of wherever you unpacked the Apache distribution.

Configure reads in a files called Configuration, which contains settings that determine details about your installation. In the src directory you will find a sample Configuration file called Configuration.tmpl, which you can copy to Configuration to get started.

After running ''little-c'' configure, you will find a file called Configration.apaci, which is then used by Configure. So configure is really just a user-friendly wrapper on top of Configure

To configure your installation with Configure, edit Configuration and specify how you want things to be done. The most important part of this file is the section specifying what modules you want installed. This portion of the file should be fairly self-explanatory - just comment out the modules you don't want, and uncomment the ones that you want.


make, make install

Whichever way you configure the installation, you will then need to compile the code by typing make, and then install it by typing make install.


Starting your new server

One of the things that will be built is a handy utility called apachectl, which helps you to start, stop, and restart your Apache server, as well as performing a variety of other tasks. To start your Apache server, just type:


        /usr/local/apache/bin/apachectl start

(This assumes that you installed Apache in /usr/local/apache, which is the default location.)


In future articles

In upcoming articles, I'll discuss in more detail what you can do with configure to make your Apache server exactly like you want. And I'll talk about what the configuration process will be like in Apache 2.0.

And, in a future article, I'll talk about apachectl, and what you can do with it, other than just starting your server.

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved