Custom Search

Friday, 7 October 2011

How to install and configure Apache on RedHat

How to install and configure Apache on RedHat and derivatives

In this tutorial, I am going to show you how to install Apache and do the initial configuration for a single site. This is tutorial is intended for those new to Apache.
The steps were performed on Centos 5.3 virtual machine inside vmware player. The main daemon in RedHat and its derivatives is called httpd while its named apache2 in Debian based systems.

1. Install Apache

yum install apache

This will install Apache …..

2. Now checkout which files have been installed with the apache

rpm -ql httpd



The file we are concerned with is httpd.conf

3. Open this file in a text editor

nano /etc/httpd/conf/httpd.conf

and check DocumentRoot. This is the location where we have to place our html documents for users to access. In my case, it is

DocumentRoot “/var/www/html”

Think of DocumentRoot as corresponding to what we type before first / in web browser eg

Next check DirectoryIndex. This directive governs the default file that Apache serves when no specific file is requested by a user.

DirectoryIndex index.html index.html.var

It means that Apache will first look for index.html, if not found, then index.html.var and send it to the requesting browser. For example, typing will result in sending index.html or index.html.var to the browser. Any file other than these two needs to be specified explicitly in the browser like Remember, anything after are in DocumentRoot (/var/www/html in this case).

We will create a file index.html for our test and place some simple text in it like:

 nano /var/www/html/index.html

and paste the following text into it


<h1>My Test page</h1>


Save it by pressing


and then


4. Type in the IP or host name of your server or just localhost in the browser. Find IP with the following command

and host name with this command


To configure it to be accessible from outside, you may want an entry in DNS server pointing its domain name to Apache server’s IP.
Apache is configured.

No comments:

Post a Comment