A virtual web host is called a "virtual Web host" by running multiple Web sites on the same server, each of which does not actually occupy the entire server independently. When building a virtual Web host, you can use three ways to build virtual Web services, based on IP addresses, port-based and domain-based. It is common to build virtual Web hosts based on domain names. So let's take a look at how to build these three different virtual web hosts.
IP address based virtual host: For each virtual host using a different domain name, different IP to achieve.
Port based virtual host: This way is not used domain names, IP addresses to differentiate, but using a different port number to implement.
Domain-based virtual host: Use a different domain name for each virtual host, and the IP address and port number are unchanged.
Preparatory work
1, before building a virtual host we first create two different Web site root directory, and create the first file.
[Root@localhost/] #mkdir/usr/local/httpd/htdocs/benet
[Root@localhost/] #mkdir/USR/LOCAL/HTTPD/HTDOCS/ACCP
[Root@localhost/] #echo "
[Root@localhost/] #echo "
2, the establishment of DNS services for the virtual host to provide domain name resolution services.
How to build a DNS service please refer to article: RHEL 5 service-Deploying DNS domain name Resolution Service
3. Build the virtual Web host. It is recommended that you use a stand-alone virtual configuration file and then load these configurations through Lnclude in the httpd.conf file, which minimizes changes to httpd.conf files and facilitates the maintenance of configuration content.
Virtual host based on IP address
Use this way everyone virtual host, most of the use of domain-based approach. When building a virtual host based on an IP address, you need to add multiple network card devices to the host.
[Root@localhost/] #vim/usr/lcoal/httpd/conf/extra/httpd-vhosts.conf//Create a separate configuration file