Tuesday, May 22, 2012

How to create Virtual Host in Apache













The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

You can configure in your Apache server step by step below:

1, Enable LoadModule rewrite_module modules/mod_rewrite in file httpd.conf in apache/apache_v_x/conf directory

2, Enable Virtual hosts
Remove # in this line Include conf/extra/httpd-vhosts.conf in file httpd.conf in apache/apache_v_x/conf directory

3, Add virtual host in httpd-vhosts.conf in apache/apache_v_x/conf/extra directory
Add following script

<VirtualHost *:80>
ServerAdmin webmaster@angkordigitalsolutions.localhost
DocumentRoot "C:\wamp\www\angkordigitalsolutions"
ServerName angkordigitalsolutions.localhost
#ServerAlias www.dummy-host.localhost
#ErrorLog "logs/dummy-host.localhost-error.log"
#CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>

4, Create host in C:\Windows\System32\drivers\etc
127.0.0.1 angkordigitalsolutions.localhost

Last, you need to restart your server

Related post: How to increase web app performance better

2 comments:

  1. Very simple post but it is useful for development time

    ReplyDelete
  2. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. cheap rdp

    ReplyDelete