apache+ Setting the host header, binding multiple domain names and websites to the same port

Source: Internet
Author: User

One server installed Apache, how to bind multiple domain names and website content? The simplest way of course is to have different stations with different ports. However, you need to add a port number after the domain name to access it, not directly to the domain name. Another way is to use the host header to virtual host. Open the Apache configuration file httpd.conf Enter the following code on the last line

Namevirtualhost *:  #使用虚拟主机, 80 port <virtualhost *: > #第一个主机, 80 port DocumentRoot "D :/root/abc "#指向本地位置ServerName www.abc.com #主机名称 (note this is important, is your domain name, accurate input to succeed)</VirtualHost> # End of first host configuration <virtualhost *:> #第二个主机, 80 port DocumentRoot "D:/root/def" # Point to local location servername www.def.com #主机名称</virtualhost><virtualhost *: > #第三个主机, 80 Port DocumentRoot "D:/root/ghi" #指向本地位置ServerName www.ghi.com #主机名称</VirtualHost>

So and so on, as long as your machine performance good, bandwidth enough, more hang a few can

Aapche If you need to bind multiple domain names to an IP, it is supported. The following 2 points need to be noted:

1 The namevirtualhost switch option must be turned on,

such as: Namevirtualhost 220.231.220.231:80

2 namevirtualhost need to specify a specific port

For example ": 80", with <virtualhost 220.231.32.*:80> correspondence, otherwise will error:

Mixing * ports and non-* ports with a namevirtualhost address are not supported, proceeding with undefined results.

Translation is: Namevirtualhost address, the specified port and the non-specified port mixed use is not supported, will have the consequences of not overdue.

The consequence of not being overdue is that the 2nd one does not work, only when a site setting works.

A complete example:

# # VirtualHost example:# almost any Apache directive could go into a VirtualHost container.# the first VirtualHost secti on isUsed forrequests without a known# server name. #NameVirtualHost219.133.61.226: the<virtualhost219.133.61.226: the>ServerAdmin [Email protected]documentroot/usr/local/apache2/htdocs1servername Www.linux51.comErrorLog Logs/linux51.com-Error_logcustomlog Logs/linux51.com-Access_log Common</virtualhost><virtualhost219.133.61.226: the>ServerAdmin [Email protected]documentroot/usr/local/apache2/htdocs2servername Www.linux52.comErrorLog Logs/linux52.com-Error_logcustomlog Logs/linux52.com-Access_log Common</VirtualHost>

This article from the Baidu Library reprint

apache+ Setting the host header, binding multiple domain names and websites to the same port

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.