服务器是如何实现多台虚拟主机?服务器实现多台虚拟主机,主要有这三种方法:使用相同的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小时协助维护,同时提供快速电子化备案,免除幕布拍照。
购买入口:https://www.west.cn/services/webhosting/
独享入口:https://www.west.cn/services/webhosting/dxhosting.asp
有免费查询商标注册吗收到通知邮件网站有非法信息腾讯云服务器挂热血江湖阿里云服务器如何开多个网站邮箱服务器重建内容索引北京迈极客建筑装饰工程北京迈极客建审核拒绝模板审核被拒备案核验电话-备案平台腾讯云轻量服务器购买后在哪找