Virtual host configuration under Windows Apache

Source: Internet
Author: User

1. Apache Virtual Host:

In Apache on the virtual host specific instructions, specific reference to the Apache manual, here simply say that the virtual host is divided into two main:

1 . Host name-based virtual host (one IP address, multiple websites)

2, IP address-based virtual host (each site has a separate IP address)

Although it is two, but in fact careful comparison, you can find: based on the host name is actually very much like a special IP address-based approach, how to implement a virtual host, the idea is this:

2. Under Windows:

based on host name

set up DNS(/Hosts file on Windows) so that our domain name is resolved to a specific IP address, such as 127.0.0.10, when we access the domain name, we actually access this particular IP address

-- This IP address points to our Apache service, at this time modify our httpd.conf file to open our Mod_rewrite module

Enable our virtual host profile at the same time

Of course we can also not enable this file, and will need to configure the virtual host information directly into the httpd.conf

--httpd-vhosts.conf configuration:

The configuration in the file will have a default example, similar to this:

But there are some places to be aware of: (This is what I see in the manual that is more important, personal opinion and not fully organized)

1,the use of <VirtualHost> does not affect the Apache's listening address. You need to use listen to make sure Apache is listening to the correct address.

That is to say: This setting is in the Apache address listens to the foundation to have the function, therefore here the IP to have the function first need listen the correct set guarantee

2. Domain-based virtual hosting:

Attention:

I found in the test: When the original configuration is not modified Namevirtualhost: When the host name of the virtual host Access will always access <VirtualHost> settings, open the manual said, so I modified it into the above,

Effect:

Browser input: wangxb.com (here is one of my thinkphp items)

Browser input: webroot.com (this I bound to the WWW root directory)

IP address-based virtual host:

The above is basically based on the host name of the virtual host settings, very simple, the following IP-based virtual host is simpler, because my feeling is: based on the host name of the virtual host is a special case of IP-based virtual host, why do you say so?

A: Because we can consider the host name based on the IP-based, but there are two domain names based on the same IP, that is to say: There are two <VirtualHost> above the set of IP and port is the same, but the ServerName and DocumentRoot Settings are not the same.

Well, let's take a look at the IP-based settings, as far as the configuration of the httpd.conf need not be modified, mainly to modify

/Hosts file, that is, bind the domain name to a different IP

Again, modify the/httpd-vhosts.conf file.

We see two two domain two IP, the corresponding DocumentRoot is not the same.

Effect: The effect in the browser is the same as the above effect, here we use the F12 network to see

Webroot.com

Network

Wangxb.com

Network

Okay, here's the setup for the virtual host. Here is a simple introduction, Apache's Chinese manual has been very good, only a few basic web development knowledge, the manual is fully readable, and said very detailed. Everyone in the configuration, there are problems can go to a good look at the manual

Special emphasis:

1, each step above the Apache configuration file modification must restart the Apache service

2, when you modify the Hosts file may prompt you insufficient authority

3. When you edit the httpd.conf file, enable the virtual host configuration file , you may experience this situation:

let me depressed for two hours of problems, inexplicable no authority, think I when in window will this ah? For a moment I was at a loss, if it is Linux, I will go back to LL-chmod, but this is Windows Ah, how can this, think about just how to do so, all again restore, restart service, finally found that the above is the reason to open the virtual host configuration file, When we open the configuration of the virtual host, we must set the correct httpd-vhosts.conf

The above is the window on the Apache virtual host configuration, for Linux under the configuration is similar, there is time I will continue to write Linux configuration and Niginx configuration, ah so much, if all write estimates too long also no one to see, ah haha 、、、 Separate space small point, we see also targeted, need to see that article.



From for notes (Wiz)



Virtual host configuration under Windows Apache

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.