Apache Web-Server Installation on CentOS/RHEL

This guide explains how to install Apache Web Server on CentOS/RHEL based systems.

Apache Server Installation

Execute the following command to install the latest Apache Server from basic CentOS/RHEL repositories:

# yum install httpd

Set the Apache Server daemon to start at boot.

# chkconfig httpd on

Basic Apache Configuration

Backup the Apache configuration file httpd.conf.

# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup

Open the Apache configuration file and un-comment the line, containing the text “NameVirtualHost *:80”.

# vi /etc/httpd/conf/httpd.conf

Save and close the file.

Firewall opening for Apache Server

Add the rules to IPTABLES.

# vi /etc/sysconfig/iptables

Append the following lines before the REJECT line, to open http and https ports 80 and 443:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Save and close the file. Restart the firewall.

# service iptables restart

Confirming the Apache Server Installation

Start the Apache HTTP Server daemon.

# service httpd start

Visit http://localhost/ in your web browser, if you’ve installed server on your local machine, or enter the server’s IP address. You should see an Apache Test Page.