一、配置httpd.conf文件

开启vhost模块

包含对应的文件

[root@CentOS6 bin]# vim/etc/httpd/httpd.conf

 

LoadModule vhost_alias_modulemodules/mod_vhost_alias.so

 

Include /etc/httpd/extra/httpd-vhosts.conf

 

注释掉这个

 

#DocumentRoot"/usr/local/apache/htdocs"

二、配置httpd-vhost.conf文件

[root@CentOS6 bin]# vim/etc/httpd/extra/httpd-vhosts.conf

把给的例子注释掉

加上下面这个

<VirtualHost 192.168.66.100:80>

   ServerAdmin 479714212@qq.com

   DocumentRoot "/usr/local/apache/htdocs/www.huangbaoying.com"

   ServerName www.huangbaoying.com

   ErrorLog "logs/www.huangbaoying.com-error_log"

   CustomLog "logs/www.huangbaoying.com-access_log" common

</VirtualHost>

 

三、在你指定的DocumentRoot中编写index.html

然后保存。

 

四、在你本地的hosts文件中添加

 

这个文件在

 

C:\Windows\System32\drivers\etc

 

192.168.66.100       www.hby.com

 

然后保存

五、重新启动apache

关闭防火墙

在浏览器中访问www.hby.com看看能不能访问到