Apache 虚拟主机的配置

来源:互联网 发布:淘宝基础版全屏代码 编辑:程序博客网 时间:2024/05/16 23:55
配置虚拟主机的步骤:


① 找到Apache配置文件httpd.conf,让Apache服务器加载配置虚拟主机的文件:
#Include conf/extra/httpd-vhosts.conf,将前面的注释去掉
② 修改本机C:\Windows\System32\drivers\etc\host文件把不同的主机名指向相对应的ip
例如:  ip   域名  127.0.0.1   www.baidu.com
? 在apache/conf/extra/httpd-vhosts.conf的末尾写上:
#配置虚拟主机成功
<VirtualHost  *:80>
   ServerName 域名
   documentRoot  网站的根目录路径
   DirectoryIndex  直接访问的文件(不是网站根目录)
</VirtualHost>
<Directory "网站的根目录路径">
     Options Indexes FollowSymLinks
     AllowOverride None  //是否开启对url的重写
     Order allow,deny    //先允许再禁止
     Allow from all    //允许所有主机访问
</Directory>

④ 重启服务器



请再此复制配置代码

<VirtualHost  *:80>   ServerName域名   documentRoot  网站的根目录路径   DirectoryIndex  直接访问的文件(不是网站根目录)</VirtualHost><Directory "网站的根目录路径">     Options Indexes FollowSymLinks     AllowOverride None     Order allow,deny     Allow from all</Directory>


0 0