您的位置:首页 > 运维架构 > Apache

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

2014-12-13 22:38 447 查看
Apache配置虚拟目录

在httpd.conf文件中添加 大约在245行

# Create Virtual catalogue
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
Alias /MyWeb "c:/MyWeb" // 在C盘的根目录下有一个Myweb文件夹,可以把这个文件夹看做虚拟目录
<Directory c:/MyWeb>
Order allow,deny
Allow from all
</Directory>
</IfModule>


Apache配置虚拟主机

在httpd文件中打开Virtual Host 大约在480行

# Virtual hosts 配置虚拟主机
Include conf/extra/httpd-vhosts.conf

接下来修改conf/extra/httpd-vhosts.conf文件

在最后一行添加

#配置自己的虚拟主机
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/MyWeb"
DirectoryIndex index.html index.htm index.php
<Directory />
Options FollowSymLinks
#Not allow others to correct our page
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


最后一项

修改hosts 文件 windows->system32->Drivers->etc->hosts

添加 127.0.0.1 www.baidu.com

完了之后,从此以后就上不去百度了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: