Installing and Configuring Apache on Linux

Apache is preinstalled on our Linux Dedicated Plans to help you set up websites on your server.

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

Apache has been the most popular web server on the Internet since April of 1996. The November 2005 Netcraft Web Server Survey found that more than 70% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined.

The Apache HTTP Server is a project of the Apache Software Foundation.

Installation of Apache should be done using Yum. You also need to have root credentials. To install Apache, execute this command:

[root$server ~]# yum install httpd

Yum will perform the installation and all you have to do is edit the Apache configuration file. Once Apache is installed, you will need to ensure that Apache is currently running:

[root$server ~]# service httpd start

Next, ensure that Apache starts at boot time:

[root$server ~]# chkconfig --level 3 httpd on

The first file to edit is /etc/hosts. Open up the file with your favorite text editor:

[root$server ~]# vi /etc/hosts

You should see something similar to this (do not remove the following line, or various programs that require network functionality will fail): localhost.localdomain localhost

You need to add a line including your IP address, domain name and your host name. Here is an example for reference (do not remove the following line, or various programs that require network functionality will fail): localhost.localdomain localhost example

Save the file and move on to the next one, /etc/sysconfig/network:

[root$server ~]# vi /etc/sysconfig/network

You should see something similar to this:


Edit the file to use your domain name:


/etc/httpd/conf/httpd.conf is the next file that needs to be edited. This is the main Apache configuration file. Open the file in vi:

[root$server ~]# vi /etc/httpd/conf/httpd.conf

The first line we need to change is the Listen line:

Listen: Allows you to bind Apache to specific IP addresses and/or ports, in addition to the default. See also the directive.

Change this to Listen on specific IP addresses as shown below to prevent Apache from glomming onto all bound IP addresses (

Listen 80

Edit the Listen line to include you IP address and port number:


The next line to look for is the ServerAdmin line:

ServerAdmin: Your address, where problems with the server should be e-mailed. This address appears on some server-generated pages, such as error documents. e.g.

ServerAdmin root@localhost

Edit the ServerAdmin to include you email address:


Now look for the ServerName line:

ServerName gives the name and port that the server uses to identify itself. This can often be determined automatically, but we recommend you specify it explicitly to prevent problems during startup.

If this is not set to valid DNS name for your host, server-generated redirections will not work. See also the UseCanonicalName directive.

If your host doesn't have a registered DNS name, enter their IP address here. You will have to access it by its address anyway, and this will make redirections work in a sensible way.


Edit the ServerName line to include your domain name and port:


This should be the minimum to get the server ready to serve pages to the Internet. Restart Apache using the following command:

[root$server ~]# service httpd restart

Open up your web browser and point to your IP address and then your domain name to verify that Apache is working.

Add Feedback