Tuesday, March 15, 2011

Step-by-Step Installation of Apache HTTP Server on Linux

Introduction

This procedure walks you through a step-by-step, default installation of Apache HTTP Server 2.2.17 onto Red Hat Enterprise Linux Server 5.4 running within VMware Player 3.1.3.  Installation involves two main steps: 1) build and install Apache HTTP Server and then 2) verification and testing. You'll take the binary installation approach.  All references used in helping write this procedure are provided in the References section, at the bottom.

Procedure

Step 1: Build and Install

Download the Apache HTTP Server 2.2 source code, which for this walkthrough is http-2.2.17.tar.gz. By default this downloads to the Linux desktop.


To unpack the downloaded file, you have two options: use copy and paste methods or run commands.  We'll do both. Let's do the command line method first.

Open a terminal, and then navigate to the directory containing the downloaded binary.  Copy binary to a standard location and then extract it.  To do this, run each of the following commands:
# cp -p httpd-2.2.17.tar.gz /usr/local/src/
# cd /usr/local/src
# tar xvzf httpd-2.2.17.tar.gz
After a few moments, you should see something like that shown below:


Now for the GUI method.  Double-click on the downloaded binary, http-2.2.17.tar.gz.  A file browser will open listing the contents, which will be the httpd-2.2.17 folder.  Copy and paste this folder to /usr/local/src/, which is a good general location for storing them.  You should see something similar to that shown below.  Note that the command line exercise, above, you also made a copy of the compressed binary and placed it in the same location.


Now for installation.  A pretty good location to install applications to is the /usr/local directory.  You can use any directory, but it's helpful to be consistent.  I use this directory.  Now let's build and install.  Run each of the following commands:
# cd /usr/local/src/httpd-2.2.17
# ./configure --prefix=/usr/local/apache --enable-so
Configuration will take approximately one minute.


After configuration is completed, you need to compile the build.  Run the following command from within the httpd-2.2.17 directory:
# make
Building the installation will take approximately three minutes.

Once the build is compiled, you are ready to install.  Run the following command from within the httpd-2.2.17 directory:
# make install
Installing the application will take approximately three minutes.  On completion of the installation, you should see something like that shown in the figure below:

This completes build and installation.  The next step involves verification and testing of your Apache HTTP Server version 2.2.17.

Step 2: Verification and Testing

Open a file browser, and then navigate to /usr/local/.  You should see something like the following:


Let's check Apache configuration using the Apache configuration testing tool.  From the terminal prompt, enter the following command:
# /usr/local/apache/bin/apachectl configtest
This error-checking tool scans the configuration for common errors.  If everything's OK, you should see something like that shown below:


The Syntax OK message indicates that it's OK startup Apache.  At the terminal prompt, run the following command:
# /usr/local/apache/bin/apachectl start
Nothing is returned after running this command.


Now to verify that the Apache HTTP Server is indeed running.  First, get the IP address of your instance.  Run the following command:
# /sbin/ifonfig
Your IP address is displayed after inet addr.


For this step-by-step walkthrough, the IP address is: 192.168.52.128.  Open a browser, and then enter: http://ip-address/.  You should see something like the following in your browser:


Congratulations!  You've installed and launched Apache HTTP Server 2.2.17 on your Linux server.

References
Notes
  • Apache HTTP Server runs as a standalone daemon process. 
  • In order view its status, you can't use the Linux service command but must first enable status information, and then use the apachectl interface.

No comments: