Apache Virtual Hosting configuration in Linux

Posted: 24 Mar 2015 in LINUX
Tags: , , , ,

First of all you need to understand what the hell is this Apache Virtual Hosting?

Answer is simple and staright forward. setting up more then One Host/Site over Single Server is called Virtual Hosting.

There are mainly two types of Virtual Hosting :

1) Name Based Virtual Hosting
2) IP Based Virtual Hosting

1) Name Based Virtual Hosting : Running multiple virtual hosts over a Single IP

2) IP Based Virtual Hosting : When a Server is having multiple IP’s and per IP is having it’s own Virtual Host is called IP Based Virtual Hosting.

Now its time to see how to Setup and configure Name Based Virtual Hosting and IP Based Virtual Hosting?

Name Based Virtual Host :

Go to this file and add lines given below at the end of this file: /etc/httpd/conf/httpd.conf

Listen 192.168.2.1:80

NameVirtualHost 192.168.2.1:80

ServerName localhost
DocumentRoot /var/www/html

Directory /var/www/html

ServerName satish.com
ServerAlias http://www.satish.com
DocumentRoot /var/www/html/satish

AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All

CustomLog logs/firstsite_access.log common
ErrorLog logs/firstsite_error.log

————————————————————————————————

IP Based Virtual Host:

#vim /etc/httpd/conf/httpd.conf

Listen 192.168.1.1:80
Listen 192.168.1.2:80

ServerName localhost
ServerAlias localhost.localdomain
DocumentRoot /var/www/html

ServerName tiwary.com
ServerAlias http://www.tiwary.com
DocumentRoot /var/www/html/tiwary

AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All

CustomLog logs/firstsite_access.log common
ErrorLog logs/firstsite_error.log

ServerName shivangi.com
ServerAlias http://www.shivangi.com

DocumentRoot /var/www/html/shivangi

AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All

CustomLog logs/second_access.log common
ErrorLog logs/second_error.log

 

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.