1 Apache虚拟主机的实现方式有3种。

  • 基于IP的虚拟主机
  • 基于端口的虚拟主机
  • 基于域名的虚拟主机

2.1基于域名的虚拟主机

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
打开apache\apache2.4.9\conf\extra文件目录下的 httpd-vhosts.conf

  增加

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com          //
    DocumentRoot "E:/WWW/blogdemo2-master"
    ServerName jizi.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

常见错误

配置好域名之后出现同一域名指向根目录

  

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄