blueice 发表于 2018-11-22 12:57:58

apache 虚拟主机

  1 基于端口的虚拟主机
  2 基于IP 的虚拟主机
  3 基于域名的虚拟主机    请求报文的首部   host
  整个配置文件分为三段   全局中心主机   虚拟主机
  主服务器和虚拟主机不可以并存 使用虚拟主机,关闭主服务器   注释DocumentRoot
  虚拟主机的定义
  
  ServerName
  DocumentRoot
  /VirtualHost>
  1 基于端口的虚拟主机
  192.168.200.128:80   /www/docs1
  192.168.200.128:8080   /www/docs2
  Listen 80
  Listen 8080
  
  ServerName www.daphne.com
  DocumentRoot/www/docs1
  /VirtualHost>
  
  ServerName www.daphne.net
  DocumentRoot /www/docs2
  /VirtualHost>
  主机名可以相同
  2 基于IP 的虚拟主机
  192.168.200.128:80 /www/docs1
  192.168.200.129:80 /www/docs2
  Listen 80
  
  ServerName www.daphne.com
  DocumentRoot /www/docs1
  /VirtualHost>
  
  ServerName www.daphne.net
  DocumentRoot /www/docs2
  /VirtualHost>
  3 基于域名的虚拟主机
  2.2 版本启动   NameVirtualHost
  192.168.200.128:80 /www/docs1      www.daphne.com
  192.168.200.128:80 /www/docs2      www.daphne.net
  NameVirtualHost192.168.200.128:80   此处要与后面VirtualHost保持一致
  Listen 80
  
  ServerName www.daphne.com
  DocumentRoot /www/docs1
  /VirtualHost>
  
  ServerName www.daphne.net
  DocumentRoot /www/docs2
  /VirtualHost>



页: [1]
查看完整版本: apache 虚拟主机