本地机apache配置基于域名的虚拟主机详解

1.打开apache的httpd.conf文件,找到
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
这一段把Include conf/extra/httpd-vhosts.conf前面的"#"去掉。

2.修改位于(win7)c:/windows/system32/drivers/etc/目录下的hosts文件
增加一段:127.0.0.1 x.acme.com(你用来访问的域名)

3.我用的是wamp包,所以到c:/wamp/bin/apache/Apache2.2.11/conf/extra目录下
修改文件httpd-vhosts.conf
NameVirtualHost默认如下:
NameVirtualHost *:80

增加:

ServerAdmin x@acme.com
DocumentRoot "/var/www/html"
ServerName x.acme.com
ErrorLog "logs/x.acme.com-error.log"
CustomLog "logs/x.acme.com-access.log" common


改好然后重启服务器。
在浏览器中输入http://x.acme.com就可以到你的目录.

当然如果你是想在现有的web服务器上增加虚拟主机,那么原来localhost的服务要能用的话,需要在上面的基础上加点东西:
hosts文件里加上:127.0.0.1 localhost
并在httpd-vhosts.conf文件里增加:

ServerAdmin localhost@xxx.com
DocumentRoot "/var/www/"
ServerName localhost
ErrorLog "logs/ localhost-error.log"
CustomLog "logs/ localhost-access.log" common

博乐网站建设公司成都创新互联公司,博乐网站设计制作,有大型网站制作公司丰富经验。已为博乐千余家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的博乐做网站的公司定做!
标题名称:本地机apache配置基于域名的虚拟主机详解
文章位置:http://hxwzsj.com/article/cpgo.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 成都网站建设 成都网站制作 营销网站建设 网站建设费用 网站设计制作 公司网站建设 成都网站建设 网站设计 网站设计制作报价 商城网站建设 定制级高端网站建设 定制网站建设多少钱 响应式网站设计方案 专业网站设计 四川成都网站制作 成都网站建设 定制网站设计 成都企业网站建设公司 成都网站制作 成都网站建设公司 成都网站制作 成都网站设计