服務(wù)器是如何實(shí)現(xiàn)多臺(tái)虛擬主機(jī)?服務(wù)器實(shí)現(xiàn)多臺(tái)虛擬主機(jī),主要有這三種方法:使用相同的ip地址,不同的端口;使用不同的ip地址;使用相同的ip和相同tcp端口,不同的主機(jī)頭。
1、使用相同的ip地址,不同的端口
只需要一個(gè)ip,通過不同端口,來搭建空間
server {
listen 80;
location / {
root html/abc;
index index.html index.htm index.php;
}
}
server {
listen 8080;
location / {
root html/cbd;
index index.html index.htm;
}
}2、使用不同的ip地址
使用同一個(gè)端口,不同ip來實(shí)現(xiàn)。每個(gè)空間分配一個(gè)ip來做區(qū)分
server {
listen 192.168.10.42:80;
location / {
root html/abc;
index index.html index.htm index.php;
}
}
server {
listen 192.168.10.52:80;
location / {
root html/cbd;
index index.html index.htm;
}
}3、使用相同的ip和相同tcp端口,不同的主機(jī)頭
server {
listen 80;
server_name www.abc.com;
location / {
root html/web1;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.cbd.com;
location / {
root html/web2;
index index.html index.htm;
}
}以上是關(guān)于“服務(wù)器是如何實(shí)現(xiàn)多臺(tái)虛擬主機(jī)”的介紹,如需購買虛擬主機(jī),推薦西部數(shù)碼,虛擬主機(jī)產(chǎn)品豐富,從共享到獨(dú)享虛擬主機(jī)均有;linux系統(tǒng)、windows系統(tǒng)主機(jī)配備齊全,如php虛擬主機(jī)、asp虛擬主機(jī)、java虛擬主機(jī)等。且,價(jià)格便宜、支持試用、技術(shù)客服7*24小時(shí)協(xié)助維護(hù),同時(shí)提供快速電子化備案,免除幕布拍照。
購買入口:https://www.west.cn/services/webhosting/
獨(dú)享入口:https://www.west.cn/services/webhosting/dxhosting.asp