What is a VM:
Using software and hardware technology, a host is divided into one "virtual" host, each host has an independent website, domain name
Nginx virtual host type:
IP-based
Based on Domain Name
Port-based
Add two ip aliases in eth0
Ifconfig eth0: 1 192.168.22.11 broadcast192.168.22.255 netmask 255.255.255.0
Route add-host 192.168.22.11 Dev eth0: 1
Ifconfig eth0: 2 192.168.22.12 broadcast192.168.22.255 netmask 255.255.255.0
Route add-host 192.168.22.12 Dev eth0: 2
Note: ifconfig
This command can be manually started, observed, and set network interface parameters.
Format: ifconfig interface [Options]
Interface: network interfaces, such as eth0, eth1, and ppp0;
Options parameters that can be set:
Up | down: Enables or disables network interfaces.
Netmask: Subnet Mask
Broadcast: broadcast address
MTU: Maximum Transmission Unit (byte)
Note: ifconfig eth0: 0 [IP] indicates setting another simulated network interface on the network interface.
Route
1. # route [-nee]
This command is used to query route information.
-N: no communication protocol or host name is used, and route information is directly displayed using IP address or port number.
(This method shows the route information quickly)
-Ee uses more detailed information for display.
2. # route add | del [-net |-host] [network segment or host] netmask [mask] [GW | Dev]
Add or delete route Parameters
Netmask, which is related to the CIDR block. Setting the netmask value can determine the size of the CIDR block.
GW, abbreviated as gateway
Dev specifies that the NIC is online and then connected to eth0.
Add the last two sentences to/etc/rc. Local startup.
Modify the nginx configuration file nginx. conf in/etc/nginx. conf.
Server {
# Listening IP Port
Listen 192.168.22.11: 80;
# Host Name
SERVER_NAME 192.168.22.11;
# Charset koi8-r;
# Path for storing access log files
# Access_log logs/server1.access. Log main;
Location /{
# Directory for storing webpage files
Root/usr/share/nginx/html/server1;
# Default homepage file, from left to right
Index index.html index.htm index. php;
}
Error_page 404/404 .html;
Location =/404.html {
Root/usr/share/nginx/html;
}
Other virtual hosts are configured according to this, and each server {........} Represents a virtual host
Server {
# Listening IP Port
Listen 80;
# Host Name
SERVER_NAME www.xxoo.com xxoo.com * .xxoo.com;
# Charset koi8-r;
# Path for storing access log files
# Access_log logs/xxoo. Access. Log main;
Location /{
# Directory for storing webpage files
Root/usr/share/nginx/html/server1;
# Default homepage file, from left to right
Index index.html index.htm index. php;
}
Error_page 404/404 .html;
Location =/404.html {
Root/usr/share/nginx/html;
}
This article from the "gentleman not" blog, please be sure to keep this source http://leozee.blog.51cto.com/4356026/1547905
Configure virtual hosts in nginx