Networking / Beginners

Installing Apache

The Apache web server is part of most Linux distributions, and that includes the Red Hat Linux distribution that we are using as an example. The Apache web server software is one of the components that can be selected during the operating system installation.

If Apache is not among the software you selected during the initial installation, you need to install it now. The easiest way to install software is with a package manager. There are a couple that are available, but the most popular (and the one used on our sample Red Hat system) is the RPM Package Manager (RPM). RPM can be used from the command line to manage the installation of optional software.

Use the rpm command to install the software you need, remove software you don't want, and check what software is installed in your system. rpm has many possible options, but most of them are for the developers who build the packages you want to install. For a network administrator, rpm can be reduced to three basic commands:

  • rpm -i package: The -i option is used to install software.
  • rpm -e package: The -e option is used to remove software.
  • rpm -q: The -q option is used to list a software package already installed in the computer. Use -qa to list all installed packages.

To find the Apache package delivered with the distribution, mount the Linux distribution CD-ROM, and look in the RPMS directory. Here is an example from our Red Hat system:

$ cd /mnt/cdrom/RedHat/RPMS
$ ls *apache*
apache-1.3.20-16.i386.rpm
apacheconf-0.8.1-1.noarch.rpm

This example assumes that the CD-ROM was mounted on /mnt/cdrom. It shows that two software packages related to Apache are included in the Red Hat distribution. One is the web server software, and the other is an X Window System Apache configuration tool. Install apache-1.3.20-16.i386.rpm with this command:

# rpm -i apache-1.3.20-16.i386.rpm

After installing the package, check that it is installed with another rpm command:

$ rpm -q apache
apache-1.3.20-16

This example shows Apache being installed from the Red Hat distribution CD-ROM. If your Linux distribution does not include the Apache software, or if you want the latest release, download Apache from the Internet. It is available on the network in RPM format and in binary format for systems that do not have rpm tools.

Apache software is available at httpd.apache.org in both source and binary forms. Open your browser to the Apache web page and select the Download link. Then select the Binaries link and the Linux link. This displays a list of tar files containing pre-compiled Apache software.

The binaries are listed by "machine type." Linux runs on several different platforms. Select the binary that is appropriate for your processor. Use the Linux uname command to find out your server's machine type. For example, our sample system provides the following response:

$ uname -m
i686

Download the correct binary file to a working directory. Rename the current daemon so that it is not accidentally executed in place of the new daemon, and move the new daemon into a directory reserved for third-party software. For example, on a Red Hat system, you might move the daemon to /usr/local/bin/httpd. Programs that are not managed by RPM should be installed in / usr/local or /opt. Otherwise, you impact some of the benefits of having a package manager. RPM can't verify or upgrade binaries that it doesn't manage. Placing a binary where RPM expects to find the binary that it manages can cause false RPM error messages, and may limit your ability to install RPM packages properly in the future. Here, we rename the old binary, copy the new one, and make sure to set the correct ownership and permissions for the file:

# mv /usr/sbin/httpd /usr/sbin/httpd.orig
# cp httpd /usr/local/bin/httpd
# chown root:root /usr/local/bin/httpd
# chmod 0755 /usr/local/bin/httpd
[Contents] [Next]