1、配置虚拟主机需要注解掉
# DocumentRoot "F:/www"
这样虚拟主机才会执行;配置方式:
2、在apache.conf 中解开 Virtual hosts 配置文件。
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
3、在apache/conf/extra/ 文件夹下 打开 httpd-vhosts.conf 配置虚拟主机:
注意 2.2 和2.4 在权限上有点不同。
<VirtualHost *:80> //端口号
DocumentRoot "C:/www" // 虚拟目录
ServerName www.my.com // 访问该域名是调用该配置
DirectoryIndex index.php // 默认首页
<Directory "C:/www"> // 权限设置
Allow from all // 访问所有文件(PS 适用于 apache 2.2)
Require all granted //访问所有牡目录(PS 使用与 apache2.4)
Options Indexes // 如果没有首页,显示虚拟目录下所有文件链接。
</Directory>
</VirtualHost>