Nginx 3 Application Hosting

V When using Nginx build virtual host server, each virtual WEB site has a separate "server {}" configuration section, each listening IP address and port number can be formulated alone, indifferent site name is different.

1 name-based virtual hosting

The first domain web hosting

{Server
the listen 80;
server_name www.gebi.com; modified to two different domain names

charset utf-8;

#access_log logs / gebi.access.log main; modify the virtual host log name

LOCATION / {
root html / gebi; create two different folders in the html folder, create a folder inside (format: index index.html index.htm homepage file)

index index.html index.htm;

}
}

The second domain web hosting

{Server
the listen 80;
server_name www.laowang.com; modified to two different domain names

charset utf-8;

#access_log logs / laowang.access.log main; modify the virtual host log name

LOCATION / {
the root html / laowang; html folder created in two different folders, the folders established inside (format: index index.html index.htm file homepage)
index index.html index.htm;
}

}

2 IP address-based virtual hosts

listen modify different virtual hosts different IP-listen IP: 80;

#access_log logs / laowang.access.log main; modify the virtual host log name

After modifying To restart the service, reload no effect (because after reload configuration items, listening port has not changed, it is necessary to restart the service to change the port)

 

3 Port-based virtual hosts

listen modify different virtual hosts different ports listen IP: different ports;

#access_log logs / laowang.access.log main; modify the virtual host log name

After modifying To restart the service, reload no effect (because after reload configuration items, listening port has not changed, it is necessary to restart the service to change the port) /

 

Guess you like

Origin www.cnblogs.com/shinian12138/p/11523691.html