You are on page 1of 8

Install Apache Webserver in CentOS 6.

3 /
Scientific Linux 6.3 / RHEL 6.3
March 5, 2013

~ Senthilkumar P

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:
OperatingSystem:CentOS6.332bitserver
Hostname:web.ostechnix.com
IPAddress:192.168.1.250

Client Details:
OperatingSystem:CentOS6.332bitDesktop
Hostname:client.ostechnix.com
IPAddress:192.168.1.251

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=web.ostechnix.com

2. Add the webserver hostname in etc/hosts file


[root@web~]#vi/etc/hosts
127.0.0.1localhostlocalhost.localdomainlocalhost4
localhost4.localdomain4

::1localhostlocalhost.localdomainlocalhost6
localhost6.localdomain6
192.168.1.250web.ostechnix.com
192.168.1.250www.ostechnix.com

3. Install Apache

Check and remove any previously installed packages


[root@web~]#rpmqa|grephttpd

or
[root@web~]#yumlistinstalled|grephttpd

Now install the httpd package


[root@web~]#yuminstallhttpd*y

4. Configure Apache
[root@web~]#vi/etc/httpd/conf/httpd.conf

## line no 262 - Set the server admin mail id which is used to receive
mail generated by apache ##
ServerAdminroot@ostechnix.com
## line no 276 - Set the website name ##
ServerNamewww.ostechnix.com:80
## line no 292 - Set the web pages folder ##
DocumentRoot"/var/www/html"

## line no 402 - Sent the index or home page of the website ##


DirectoryIndexostechnix.html

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/ostechnix.html
<html>
<bodybgcolor=blue>
<h1>WelcometoOSTECHNIXWebsite</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~]#serviceiptablesrestart
iptables:Flushingfirewallrules:[OK]
iptables:SettingchainstopolicyACCEPT:filter[OK]
iptables:Unloadingmodules:[OK]
iptables:Applyingfirewallrules:[OK]

7. Start Apache web server


[root@web~]#servicehttpdstart
Startinghttpd:[OK]
[root@web~]#chkconfighttpdon

Client side Configuration


1. Add the webserver and client ip address and hostname in the /etc/hosts file
[root@client~]#vi/etc/hosts
127.0.0.1localhostlocalhost.localdomainlocalhost4
localhost4.localdomain4
::1localhostlocalhost.localdomainlocalhost6
localhost6.localdomain6
192.168.1.251client.ostechnix.com
192.168.1.250www.ostechnix.com

2. Check Apache webserver

Open the firefox in client and type http://www.ostechnix.com in


the address bar. The index page of ostechnix website will open
now.

Thats it. Have a good day!!!


About these ads

Rate this:

2 Votes
Share this:

Reddit

Facebook5

Google

Twitter1

LinkedIn3

Digg

StumbleUpon

Email

Print

Google+

Senthilkumar P

This entry was posted in CentOS, Linux, RHEL, Scientific Linux and
tagged Apache, Webserver. Bookmark the permalink.

Post navigation
Setup Mail Server using Postfix, Dovecot and SquirrelMail in
CentOS/RHEL/Scientific Linux 6.3 step by step
FF Multi Converter An awesome multi converter for Audio/Video,
Images and Documents

6 thoughts on Install

Apache Webserver
in CentOS 6.3 / Scientific Linux
6.3 / RHEL 6.3

1.

Ziko
May 11, 2013 at 1:05 pm
Thank You Guys!
Reply

2.

Rob
May 29, 2013 at 11:44 pm

Why is the same iptables rule added twice? Did you mean for the
second one to allow udp packets?
Reply
SK

May 30, 2013 at 12:56 pm


Yes thats correct.
Reply
3.

honore
June 3, 2013 at 6:06 pm
thanks bro nice
Reply

4.

UMER AZEEM
July 9, 2013 at 12:44 am
Nice Sharing fir bignners like meThank you.
Reply

5.

venkat
November 20, 2013 at 4:28 pm
Good
Reply
Leave a Reply

Blog Stats

601,943 Views
Search

Categories

Archives
Like us on Facebook
Subscribe Newsletter
Enter your Email address to subscribe free Newsletter

Join 210 other followers

Subscribe

Recent Posts

Setup FTP Server step by step in CentOS / RHEL / Scientific Linux 6.3/6.4/6.5

Setup NFS Server in CentOS / RHEL / Scientific Linux 6.3/6.4/6.5

Setup DNS Server step by step in CentOS 6.3/6.4/6.5 / RHEL 6.3/6.4/6.5 /


Scientific Linux 6.3/6.4/6.5

Setup Social Publishing CMS(Content Managemnet System) using Pligg

Setup Your Own Twitter like Website Using StatusNet

Top Posts & Pages

Setup FTP Server step by step in CentOS / RHEL / Scientific Linux 6.3/6.4/6.5

Setup DNS Server step by step in CentOS 6.3/6.4/6.5 / RHEL 6.3/6.4/6.5 /


Scientific Linux 6.3/6.4/6.5

Setup Mail Server using Postfix, Dovecot and SquirrelMail in


CentOS/RHEL/Scientific Linux 6.3 step by step

How to install telnet in CentOS / RHEL / Scientific Linux 6.4

Linux Basics - LVM (Logical Volume Manager) Tutorial

Install Subversion server in CentOS 6.4 / RHEL 6.4 / Scientific Linux 6.4

Setup NFS Server in CentOS / RHEL / Scientific Linux 6.3/6.4/6.5

Setup Local YUM Server in CentOS 6.x / RHEL 6.x / Scientific Linux 6.x

Setup LDAP server (389 Directory Server) in CentOS/RHEL/Scientific Linux 6.3


step by step.

How to resolve "add-apt-repository: command not found" error in Ubuntu


12.10
Create a free website or blog

You might also like