Saturday, January 23, 2010

Apache Virtual Hosting Configuration in RHEL 5


Apache Virtual Hosting Configuration

Host based virtual hosting:
system1: setup apache virtual host

Step 1:Install http packages
#yum install httpd
Step 2:Create html files
#vi /var/www/html/main.html

Sample Web Page

This is page of vv.com

#mkdir /var/www/mail
#vi /var/www/mail/mail.html

Sample Web Page

Welcome to Home Page of vv.com

Step 3:Add html page to http configuration file
#vi /etc/httpd/conf/httpd.conf
Line no: 390
Directory Index mail.html main.html index.html index.html.var
Line no: 998 or Last
NameVirtualHost 192.168.0.25:80

Servername www.vv.com.
DocumentRoot /var/www/html


Servername mail.vv.com.
DocumentRoot /var/www/mail

Step 4:restart the http service
#service httpd restart
sys1:
add dns entries in /etc/resolv.conf
#vim /etc/resolv.conf
search vv.com
nameserver 192.168.0.25
Step 5:open firefox and type the following url in address bar
http://www.vv.com
http://mail.vv.com


IP based virtual hosting:system1:
Step 1:create ethernet alias ip address is 10.0.0.10
#netconfig d eth0:1
#service network restart
add host the entries in dns
#cat>>/var/named/chroot/var/named/rhel5.com.db
vvlinux IN A 10.0.0.10

reload the dns entries
#rndc reload
Step 2:Install http packages
#yum install httpd
Step 3:Create html files
#mkdir /var/www/vvlinux
#vi /var/www/mail/vvlinux.html

Sample Web Page

Welcome to Home Page of vvlinux.com

Step 4:Add html page to http configuration file
#vi /etc/httpd/conf/httpd.conf
Line no: 390
Directory Index vvlinux.html mail.html main.html index.html
Line no: 998 or Last
NameVirtualHost 192.168.0.25:80

Servername www.vv.com.
DocumentRoot /var/www/html


Servername mail.vv.com.
DocumentRoot /var/www/mail

NameVirtualHost 10.0.0.10:80

Servername vvlinux..vv.com.
DocumentRoot /var/www/vvlinux

Step 5:restart the http service
#service httpd restart
sys1:
add dns entries in /etc/resolv.conff
#vi /etc/resolv.conf
Step 6:open firefox and type the following url in address bar
http://www.vv.com
http://mail.vv.com
http://vvlinux.vv.com
Finally apache virtual host configure successfully.


No comments:

Post a Comment