Virtual Host Principle

Source: Internet
Author: User

A vm is used to run several websites, provide WEB, FTP, Mail, and other services on a server. This topic describes WEB Service virtual host settings.

There are two ways to implement a VM: IP-based and host name-based.

IP-based method:


First, bind multiple IP addresses to the server, configure the WEB server, and bind multiple websites to different IP addresses. Access different IP addresses to view different websites.

Host Name-based method:

First, set the records of multiple domain names so that they are resolved to the same IP address, that is, the same server. Then, configure the WEB server on the server, add multiple websites, and set a host name for each website. The HTTP request contains the host name information. When the WEB server receives an access request, it can access different websites based on different host names.

The basic IP address method is commonly used in LAN, and the host name-based method is commonly used in Internet. The following describes how to set the host name-based virtual host based on two common WEB servers, IIS and Apache.

 

To set up a VM, follow these steps:

1. add multiple domain names in the dynamic domain name client software. The purpose of this step is to resolve these domain names to the same server. (Note: You can add multiple domain names to the public network client and the TrueHost client of the Intranet Professional Edition. The intranet Standard Edition does not support multiple domain names ).

2. Add a domain name to your WEB server (such as IIS and Apache) to configure the VM.

 

 

 

IIS virtual host settings

 

1. Choose Control Panel> Administrative Tools> Internet Service Manager> default web site ".

2. Right-click the "Default web site" and choose "New"> "Site ". Click "Next ".

3. Enter the site description, for example, site 1 ". Click "Next ".

4. Enter the domain name on the "host header of the site", for example, "abc.dns0755.net ". Click "Next ".

5. Specify the root directory path of the site in the path. Click "Next ".

6. select an appropriate permission from the permission list. Click "Next.

If you configure a virtual host with a top-level domain name, for example, enter "abc.com" in the Host Header in step 1 above, and you also want to use "www.abc.com" for access. The procedure is as follows:

1. Right-click site 1 in Internet Service Manager and select Properties ".

2. Click "advanced" on the right of the IP address ".

3. Click "add", enter the port number (usually 80), and then enter the host header name "www.abc.com ".

 

If you want to add multiple sites, repeat the preceding steps.

 

 

 

Apache Virtual Host settings

 

1. Open the Apache configuration file "httpd. conf", find "# NameVirtualHost *", and remove "#" before this line.

2. Add a virtual host site under the "NameVirtualHost *" line. Example:

<VirtualHost *>
ServerAdmin webmaster@comexe.cn
DocumentRoot/export/home/dns0755
ServerName dns0755.net
ServerAlias * .dns0755.net
ErrorLog "|/usr/local/sbin/rotatelogs/var/log/http/dns0755-err.log 604800"
CustomLog "|/usr/local/sbin/rotatelogs/var/log/http/dns0755.log 604800" combined
</VirtualHost>

Note:

ServerAdmin webmaster@comexe.cn
Site administrator Email address

DocumentRoot/home/dns0755
Site root directory

ServerName dns0755.net
Site Host Name

ServerAlias * .dns0755.net
Site alias. "*" indicates any character

ErrorLog "|/usr/local/sbin/rotatelogs/var/log/http/dns0755-err.log 604800"
Error Log Control

CustomLog "|/usr/local/sbin/rotatelogs/var/log/http/dns0755.log 604800" combined
Access log

/Usr/local/sbin/rotatelogs is a log management program
/Var/log/http/dns0755.log is the log file name
The unit of 604800 is seconds, which indicates that a log file is generated every 7 days.

If you want to add multiple sites, repeat Step 1.

 

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.