Tag: Port-based IP for virtual host port-based virtual host domain-based virtual host
In yesterday's blog, mainly introduced the Apache configuration file, in this configuration file, we mainly introduced the Apache configuration file in the main parameters, there is a part about the virtual host parameters we did not say, deliberately to take this instruction to today.
The so-called virtual Machine Host: is a Web server made up of multiple sites to use, an Apache service to serve a number of different sites. In fact, the popular understanding is that a Web server as a multiple Web server meaning.
Type of virtual host:
1. IP-based virtual host
Example: ip1:80
Ip2:80
IP-based virtual host IP address does not pass, the port number (80) is the same.
Because the IPv4 address is scarce, it is generally not used as a way to build a virtual host
2. Port-based virtual host
Example: ip:80
ip:8080
This way the virtual host, the IP address is the same, but the port number is different. In general, we often say that the port number of the Web server is 80, so when you use another port number, which can cause many people do not know, and therefore can not access your Web server, generally on the internet this way is not commonly used.
3. Domain-based virtual host
such as ip:80
Servername:www.a.com
Ip:80
Servername:www.b.net
Domain-based virtual host, IP address and 80 port is the same, the only difference is the servername hostname is not the same. Using a domain-based virtual host, the hostname must be able to be resolved by DNS, and no side error will occur. So either modify the local Hosts file or assume a DNS server. Here I directly modify the local Hosts file, add a few mapping relationships can be. This way the virtual host is the most used.
Things to keep in mind when building a virtual host:
1, because the virtual host and physical host (central host) can not be effective at the same time, so in the construction of virtual host, you need to unregister the physical host (central host), that is, in the/etc/httpd/conf/httpd.conf file DocumentRoot this line comment out.
2, enable the virtual host, that is, the Apache configuration file Namevirtualhost *:80 this line
Definition of a virtual host
The definition of a virtual host uses
<virtualhost ip:port>
This can be stored in a number of parameters or instructions, in the same form as the definition <Directory></Directory>
</VirtualHost>
Definition of URL
In the Apache configuration file There is a container like this
<Location/server-info>
SetHandler Server-info
Order Deny,allow
Deny from all
Allow from. example.com
</Location>
This container is used to define the URL, in <Directory></Directory> this container, the definition of the local path, remember that the URL and local path is not matter, just the same way.
This article from the "Linux Learning Path" blog, declined reprint!
Linux Learning path Apache virtual host