需求:
- 输入www.baidu.com 打开web1的网站
- 输入www.sina.com打开web2的网站
复制代码配置过程: 要配置虚拟主机,需要在httpd.conf中引入虚拟主机的培训文件(vhosts.conf)
虚拟主机配置
vhosts.conf配置如下
- <VirtualHost _default_:80>
- DocumentRoot "C:\web1" #指定虚拟目录路径
- ServerName www.baidu.com # 虚拟目录绑定的域名
- DirectoryIndex aa.php # 默认首页
- <Directory "C:\web1">
- Options -Indexes -FollowSymLinks +ExecCGI
- AllowOverride All
- Order allow,deny
- Allow from all
- Require all granted
- </Directory>
- </VirtualHost>
- <VirtualHost _default_:80>
- DocumentRoot "C:\web2"
- ServerName www.sina.com
- DirectoryIndex bb.php
- <Directory "C:\web2">
- Options -Indexes -FollowSymLinks +ExecCGI
- AllowOverride All
- Order allow,deny
- Allow from all
- Require all granted
- </Directory>
- </VirtualHost>
复制代码
虚拟主机配置
|