0% found this document useful (0 votes)
11 views3 pages

Install Apache on CentOS 6.3 Guide

This document provides instructions for installing and configuring Apache web server on a CentOS server to host a sample website. It details the server and client system configurations, including setting the hostname and IP address, installing Apache, configuring Apache settings like ServerAdmin and DocumentRoot, creating an index.html page, opening firewall ports, and starting the Apache service. The client is then configured to access the website by adding the server hostname and IP to its /etc/hosts file and accessing the site via the server's domain name in a web browser.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Install Apache on CentOS 6.3 Guide

This document provides instructions for installing and configuring Apache web server on a CentOS server to host a sample website. It details the server and client system configurations, including setting the hostname and IP address, installing Apache, configuring Apache settings like ServerAdmin and DocumentRoot, creating an index.html page, opening firewall ports, and starting the Apache service. The client is then configured to access the website by adding the server hostname and IP to its /etc/hosts file and accessing the site via the server's domain name in a web browser.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

In this how-to tutorial Ill show you how to install Apache and host a sample website using

Apache.

Scenario
In this how-to tutorial, my test scenario setup are as follows

Webserver Details:
Operating System
Hostname
IP Address

:
:
:

CentOS 6.3 32bit server


[Link]
[Link]

:
:
:

CentOS 6.3 32bit Desktop


[Link]
[Link]

Client Details:
Operating System
Hostname
IP Address

I already have a DNS server in my setup and i had properly configured the DNS server with both
server and client details.

Server side configuration


Prerequisites:
1. Set the hostname of web server
[root@web ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=[Link]

2. Add the webserver hostname in etc/hosts file


[root@web ~]# vi /etc/hosts
[Link]
localhost [Link] localhost4 localhost4.localdomain4
::1
localhost [Link] localhost6 localhost6.localdomain6
[Link]
[Link]
[Link]
[Link]

3. Install Apache
Check and remove any previously installed packages
[root@web ~]# rpm -qa | grep httpd

or

[root@web ~]# yum list installed | grep httpd

Now install the httpd package


[root@web ~]# yum install httpd* -y

4. Configure Apache
[root@web ~]# vi /etc/httpd/conf/[Link]
## line no 262 - Set the server admin mail id which is used to receive mail
generated by apache ##
ServerAdmin root@[Link]
## line no 276 - Set the website name ##
ServerName [Link]
## line no 292 - Set the web pages folder ##
DocumentRoot "/var/www/html"
## line no 402 - Sent the index or home page of the website ##
DirectoryIndex [Link]

5. Create a sample index or home page


Create the index or home page html file in the /var/www/html/ directory
[root@web ~]# vi /var/www/html/[Link]
<html>
<body bgcolor=blue>
<h1> Welcome to OSTECHNIX Website </h1>
</body>
</html>

6. Allow webserver through firewall


[root@web ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Restart iptables to save changes


[root@web
iptables:
iptables:
iptables:
iptables:

~]# service iptables restart


Flushing firewall rules:
Setting chains to policy ACCEPT: filter
Unloading modules:
Applying firewall rules:

[
[
[
[

OK
OK
OK
OK

]
]
]
]

OK

7. Start Apache web server


[root@web ~]# service httpd start
Starting httpd:
[root@web ~]# chkconfig httpd on

Client side Configuration


1. Add the webserver and client ip address and hostname in the /etc/hosts file
[root@client ~]# vi /etc/hosts
[Link]
localhost [Link] localhost4 localhost4.localdomain4
::1
localhost [Link] localhost6 localhost6.localdomain6
[Link]
[Link]
[Link]
[Link]

2. Check Apache webserver


Open the firefox in client and type [Link] in the address bar. The index page
of ostechnix website will open now.

Thats it. Have a good day!!!

You might also like