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

文件,找到

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
这一段把Include conf/extra/httpd-vhosts.conf前面的"#"去掉。

修改位于(win7)c:/windows/system32/drivers/etc/目录下的hosts文件

增加一段:127.0.0.1 x.acme.com(你用来访问的域名)

修改文件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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...