Apache虚拟主机和虚拟目录的配置

1、虚拟路径配置

httpd.conf中配置

<IfModule dir_module>

#默认的显示页面

DirectoryIndex index.html

#映射虚拟目录

Alias /web "G:/log"

#这是访问权限

<Directory G:/log>

Order allow,deny

#阻止左右人访问

deny from all

#允许所有人访问

allow from all

</Directory>

</IfModule>

2、虚拟主机配置

1、 启用httpd-vhosts.conf

# Virtual hosts 虚拟主机 把下面的#去掉就OK...这事虚拟机设置 我们如果不映射虚拟目录不要 打开这个 否则网站不能正常访问

#Include conf/extra/httpd-vhosts.conf

2、图片httpd-vhosts.conf 虚拟主机的配置 . 对如下代码进行修改 "G:/virtual" 是虚拟路径实际对应的 目录 我们可以通过配置虚拟目录 然后绑定端口

#虚拟路径映射的配置

<VirtualHost 127.0.0.1:80>

DocumentRoot "G:/virtual"

DirectoryIndex index.html

<Directory />

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

</VirtualHost>