导读服务器是如何实现多台虚拟主机?服务器实现多台虚拟主机,主要有这三种方法使用相同的IP地址,不同的端口;使用不同的IP地址;使用相同的IP和相同TCP端口,不同的主机头。1、使用相同的IP地址,不同的

服务器是如何实现多台虚拟主机?服务器实现多台虚拟主机,主要有这三种方法:使用相同的IP地址,不同的端口;使用不同的IP地址;使用相同的IP和相同TCP端口,不同的主机头。

1、使用相同的IP地址,不同的端口

只需要一个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地址

使用同一个端口,不同IP来实现。每个空间分配一个IP来做区分

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端口,不同的主机头

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;
}
}

以上是关于“服务器是如何实现多台虚拟主机”的介绍,如需购买虚拟主机,推荐旺隆创业网,虚拟主机产品丰富,从共享到独享虚拟主机均有;Linux系统、Windows系统主机配备齐全,如PHP虚拟主机、ASP虚拟主机、Java虚拟主机等。且,价格便宜、支持试用、技术客服7*24小时协助维护,同时提供快速电子化备案,免除幕布拍照。

购买入口:http://www.dlwanglong.cn/services/webhosting/

独享入口:http://www.dlwanglong.cn/services/webhosting/dxhosting.asp