Wednesday, April 1, 2015

apache web server configuration in linux step by step

APACHE(HTTP)

Web Server is application server to provide web hosting services over internet.

Apache Web Server is the Most Popular Web Server. It is open source and flat-foam independent service.

Virtual Hosts

I.P base Virtual hosting:
It allows hosting to multiple websites on different I.P address in server.


Name Base Virtual hosting:
It allows hosting multiple websites on single public I.P address in server
Disadvantage of Name base virtual hosting is N/w traffic load on single I.P Address.


Port Base Virtual hosting:
Default Web server works on Port 80, for security reason we implement port base web-hosting to access your webpage.


Packages : http
httpd-devel

Script : /etc/httpd/conf/httpd.conf

Services & Daemon: httpd

Port number : 80

Home director : /var/www


Configuring APACHE WEB Server ( Apache )

Part One

Configuring a Single Site with www.zoom.com name at IP 192.168.0.X
Step 1) Host Entries
To Check the web server running at Server machine add the entry in /etc/hosts file

[root@web ~]# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.0.X www.zoom.com
:wq!
Step 2 ) CHECK & INSTALL PACKAGES

[root@station4 ~]# rpm -qa | grep httpd
or
[root@station4 ~]# yum list installed | grep httpd

[root@station4 ~]# yum remove httpd* -y
Method 1 :
Installing through rpm

[root@station4 ~]# mkdir /mnt
[root@station4 ~]# mount 192.168.0.250:/var/ftp/pub/Server /mnt
[root@station4 ~]# mount
[root@station4 ~]# cd /mnt
[root@station4 pkgs]# ls
[root@station4 pkgs]# rpm -ivh httpd* --force
Method 2 :
Installing through yum
[root@station4 pkgs]# yum install httpd* -y
Step 3) Edit the Main Configuration File
[root@web ~]# vi /etc/httpd/conf/httpd.conf
ServerAdmin root@zoom.com ## 250 recives mail generated by apache
server
ServerName www.zoom.com:80 ## 264 name of web sit
DocumentRoot "/var/www/html" ## 280 web pages folder
DirectoryIndex zoom.html ## 290 index or home pages
:wq!
Step 4 ) Create the resource

Create index or home html file in DocumentRoot folder i.e /var/www/html

[root@web ~]# cd /var/www/html
[root@web ~]# vi zoom.html
<html>
<body bgcolor=yellow>
<marquee> <h1> THIS IS ZOOM TECHNOLOGIES </h1></marquee>
<h6> THIS IS ZOOM TECHNOLOGIES </h6>
</body>
</html>

Step 5) START THE SERVICE
[root@web ~]# service httpd restart
Step 6 ) Open the Browser & type
http://www.zoom.com
or
http://192.168.0.X

Part TWO

Configuring a Multiple Site i.e Virtual Hosting We are going to host four sites
www.zoom.com ,www.yahoo.com, www.google.com,
www.rediff.com
1) NameBased : multiple site on single on IP 192.168.0.X1
www.zoom.com ,www.yahoo.com, www.google.com
2) Port Based: www.google.com at port 5000
3) IP BASED : 192.168.0.X2
Step 1) Host Entries

To Check the web server running at Server machine add the entry /etc/hosts file

[root@web ~]# ifconfig
Assigning default IP
[root@web ~]# netconfig
Assigning a Virtual IP
[root@web ~]# netconfig --device eth0:1

[ ] Use dynamic IP configuration (BOOTP/DHCP)
IP address: 192.168.0.X2_____
Netmask: 255.255.255.0___
Default gateway (IP): 192.168.0.254___
Primary nameserver: 192.168.0.1_____
OK Back
[root@web ~]# service network restart
[root@web ~]# ifconfig
[root@web ~]# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.0.X1 www.zoom.com
192.168.0.X1 www.yahoo.com
192.168.0.X1 www.google.com
192.168.0.X2 www.rediff.com
:wq!
Step 2 ) Repeat the Step 2 Part 1

Step 3) Edit the Main Configuration File
[root@web ~]# vi /etc/httpd/conf/httpd.conf
############ NAME BASED ###################### NameVirtualHost 192.168.0.X1:80
<VirtualHost 192.168.0.X1:80>
ServerAdmin root@zoom.com
DocumentRoot /var/www/html/zoom
ServerName www.zoom.com
DirectoryIndex zoom.html </VirtualHost>

<VirtualHost 192.168.0.X1:80>
ServerAdmin root@yahoo.com
DocumentRoot /var/www/html/yahoo
ServerName www.yahoo.com
DirectoryIndex yahoo.html
</VirtualHost>
############ PORT BASED ######################
Listen 5000
<VirtualHost 192.168.0.X1:5000>
ServerAdmin root@google.com
DocumentRoot /var/www/html/google
ServerName www.google.com
DirectoryIndex google.html
</VirtualHost>
############ NAME BASED ######################
############ IP BASED ######################
<VirtualHost 192.168.0.X2:80>
ServerAdmin root@rediff.com
DocumentRoot /var/www/html/rediff
ServerName www.rediff.com
DirectoryIndex rediff.html
</VirtualHost>

########## To authenticate Web server i.e asking username & password
for www.yahoo.com ##########

<Directory /var/www.html/yahoo>
AuthName "zoomauth"
AuthUserFile /etc/httpd/conf/htpasswd
AuthType Basic
Require v alid-user </Directory>
:wq!

Step 4 ) Create the resource
Create DocumentRoot folder for each site
[root@web ~]# cd /var/www/html
[root@web ~]# mkdir zoom yahoo google rediff
Create index or home html file respective DocumentRoot folder Similar to Step 4 part one
Step 5 ) Create a user & provide web password to access www.yahoo.com
site

[root@web ~]# useradd tom
[root@web ~]# htpasswd -c /etc/httpd/conf/htpasswd tom
Step 6) START THE SERVICES
[root@web ~]# service httpd restart
Step 7 ) Open the Browser & type
http://www.zoom.com
http://www.yahoo.com
http://www.google.com:5000
http://192.168.0.X2

Client Side Configurtion

Step 1 ) Provide the ip of DNS
Step 2 ) Open the Browser & type
http://www.zoom.com
http://www.yahoo.com
http://www.google.com:5000
http://192.168.0.X2






No comments:

Post a Comment