What is Apache Virtual Hosting?
When setting up more then One Host/Site over Single Server, this is called Virtual Hosting.
Virtual Hosting can be of 2 type's:
1) Name Based Virtual Hosting
2) IP Based Virtual Hosting
1) Name Based Virtual Hosting : Running multiple virtual hosts over a Single IP is called Name Based Virtual Hosting.
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.
How to Setup Name Based Virtual Hosting and IP Based Virtual Hosting?
Name Based Virtual Host :
edit /etc/httpd/conf/httpd.conf
Listen 192.168.1.1:80
NameVirtualHost 192.168..1.1:80
VirtualHost 192.168..1.1:80
ServerName localhost
ServerAlias localhost.localdomain
DocumentRoot /var/www/html
Directory /var/www/html
AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All
/Directory
CustomLog logs/localhost_access.log common
ErrorLog logs/localhost_error.log
/VirtualHost
VirtualHost 192.168..1.1:80
ServerName fistsite.com
ServerAlias www.firstsite.com
DocumentRoot /var/www/html/firstsite
Directory /var/www/html/firstsite
AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All
/Directory
CustomLog logs/firstsite_access.log common
ErrorLog logs/firstsite_error.log
/VirtualHost
------------------------------------------------------------------------------------------------
IP Based Virtual Host:
edit /etc/httpd/conf/httpd.conf
Listen 192.168.1.1:80
Listen 192.168.1.2:80
VirtualHost 192.168..1.1:80
ServerName localhost
ServerAlias localhost.localdomain
DocumentRoot /var/www/html
Directory /var/www/html
AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All
/Directory
CustomLog logs/localhost_access.log common
ErrorLog logs/localhost_error.log
/VirtualHost
VirtualHost 192.168..1.2:80
ServerName fistsite.com
ServerAlias www.firstsite.com
DocumentRoot /var/www/html/firstsite
Directory /var/www/html/firstsite
AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All
/Directory
CustomLog logs/firstsite_access.log common
ErrorLog logs/firstsite_error.log
/VirtualHost
VirtualHost 192.168..1.3:80
ServerName second.com
ServerAlias www.second.com
DocumentRoot /var/www/html/second
Directory /var/www/html/second
AllowOverride None
Options -Indexes -FollowSymLinks
Order allow, deny
Allow from All
/Directory
CustomLog logs/second_access.log common
ErrorLog logs/second_error.log
/VirtualHost
-------------------------------------------------------------------------------------------------
No comments:
Post a Comment