Virtual Hosting

The Virtual Hosting is nothing but running over on the web site on an internet server ex: (xyz.com ,abc.com, demo.xyz.com.)
Virtual Hosting is appropriate to accommodate additional range of website sites hosting on a single IP address. This can eliminate the priority of information science address necessities.
Virtual Hosting are often deployed on any of the webserver like Apache internet Server or IIS and Application servers (Tomcat and Jboss).

IP based Virtual Hosting

The IP based virtual hosting to apply based on IP address and associated port when request comes to a webserver, IP based virtual hosting serve different website on different IP address or Port number.

Name based virtual hosting

Name base virtual hosting is extremely straightforward to implement, solely have to be compelled to piece your DNS entry like (A record / CNAME) inform to the online server information science. The Apache internet server identifies hostname and serve the online contents mapped to a hostname.
Apache Virtual Hosting installation and configuration guide has prepare on following platform and services.

Operating System        : CentOS release 6.5 (Final) 32bit
Webserver                      : httpd-2.2.15-29.el6.centos.i686
Domain                             :demo.com or www.demo.com and demo.com or www.demo.com
Apache Webserver IP : 192.168.1.44
Scope                                  : Intranet

Dependencies:

Centos / Redhat Box : 1 No’s ( virutal / Physical)
Packages : httpd-2.2.15-29.el6.centos.i686
IP address : Public / Private ( depend on your requirement , if your hosting within Intranet private IP address enough or lese you need to Pulic IP assinged to webserver )
Domain Name : If hosting for public access, required registerd Domain Name and creating DNS entries A record pointing to webserver IP address
or
Hosting for Intranet access, required a local DNS entries associated to domain or entries in localhost hosts file from where request is orginated

Steps
Step 1: Install and configuring Apache webserver
Step 2: Hosting Website for demo.com & demo.com
Step 3: Verifying

Step 1: Install and configuring Apache webserver
1.1
Login to webserver as root user (192.168.1.44) and Install apache and php packages from repository using yum command line utility.

[root@experts ~]# yum install httpd httpd-devel php php-devel php-mysql

1.2
The default location of apache configuration and website docs
Configuration files located in : /etc/httpd/conf/
The Main configuration file : httpd.conf
Other configuration files locate in : /etc/httpd/conf.d/
The service operations like start / stop / restart can be pefromed using below command
[root@experts ~]#service httpd start
Set the Service ON at boot level

[root@experts ~]#chkconfig httpd on
1.3
Configure Virtual Hosting by editing httpd.conf file .

[root@experts ~]#vi /etc/httpd/conf/httpd.conf

Modify following context as shown below.

#NameVirtualHost *:80 (un comment NameVirtualHost *.80)
Go to last line of configuration file and add follwing context to host a website for solutionsatexperts or www.demo.com.

<VirtualHost *:80>
ServerAdmin webmaster@demo.com
DocumentRoot /sites/demo.com
ServerName demo.com
ServerAlias www.demo.com
ErrorLog logs/demo.com-error_log
CustomLog logs/demo.com-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@demo.com
DocumentRoot /sites/demo.com
ServerName demo.com
ServerAlias www.demo.com
ErrorLog logs/demo.com-error_log
CustomLog logs/demo.com-access_log common
</VirtualHost>

Save and Exit.

Note :
ServerAlias : is use to map domain prefix like *.domain.com or abc.domain.com www.domain.com

Step 2: Hosting Website for demo.com & demo.com

2.1
Create the folder /sites, /sites/demo.com , /sites/demo.com.

[root@experts ~]#mkdir -p /sites/demo.com
[root@experts ~]#mkdir -p /sites/demo.com
2.2
Change owner and group permissions (set owner and group as apache).

[root@experts ~]#chown -R apache:apache /sites/

2.3
Upload website files like (html, php & css) to each of the folder created above.
in our example we are creating index.html file in each of the folder.

[root@experts ~]#vi /sites/demo.com/index.html

<html>
<body>
<h1>Welcome to demo.com </h1>
</body>
</html>
Save & Exit.

[root@experts ~]#vi /sites/demo.com/index.html

<html>
<body>
<h1>Welcome to demo.com</h1>
</body>
</html>
Save & Exit.
change the permission for index.html files
[root@experts ~]#chown -R apache:apache /sites/
2.4
Restart Apache service using below command.
[root@experts ~]#service httpd restart

2.5
Add the hosts entry in the client machine from where we are going to visit websites (map IP to hostname).
Add IP to Hostname mapping in below file
C:\Windows\System32\drivers\etc\hosts
192.168.1.44 demo.com
192.168.1.44 www.demo.com
Save and Exit.
Optional :
If you have DNS server in intranet than create following entries in forward lookup zone.
A record 192.168.1.44
CNAME www.domainname.com

Step 3: Verifying
3.1
from CMD , Ping Hostname to IP response.
ping www.demo.com
ping demo.com
ping demo.com
ping www.demo.com

3.2
check the apache configuration syntx errors
[root@experts ~]#httpd -t

3.3
Check the logs
[root@experts ~]# tail /var/logs/httpd/demo.com-error_log

3.4
invoke the browser and visit the websites (demo.com, demo.com)

 

refer below video

Both comments and pings are currently closed.

Comments are closed.

Copyright ©Solutions@Experts.com
Copyright © NewWpThemes Techmark Solutions - www.techmarksolutions.co.uk