1.找到Apache的\conf目录下的httpd.conf文件,打开它,找到下面这两行:
# Virtual hosts#Include conf/extra/httpd-vhosts.conf
把他前边的#号去掉,修改后如下如下:# Virtual hosts
Include conf/extra/httpd-vhosts.conf意思是启用虚拟主机的设置文件httpd-vhosts.conf,虚拟主机的设置都在这个文件下设置,不用去改httpd.conf,这样比较清晰。
打开它的时候里面已经含有像下面这样的内容:
–虚拟主机配置开始<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.localhostDocumentRoot "E:/wamp/www/ecshop"//网站的根路径-虚拟主机的目录,即域名对应的根目录
ServerName "www.baidu.com"//虚拟主机域名-你想要的域名ServerAlias www.dummy-host.localhost
ErrorLog "logs/dummy-host.localhost-error.log"CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost><Directory "E:/wamp/www/ecshop">//这是你的虚拟主机的被授权的目录一般与DocumentRoot “”–虚拟主机的目录,即域名对应的根目录相同。
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride AllOrder allow,deny
Allow from all</Directory>
Allow from all - 只要allow别人才行访问上面定义的目录,否则在IE或firefox访问时会显示503错误,即禁止访问。这是Apache默认的设置,最后一行是这样的Deny from all意思是拒绝所有访问对根目录的访问,别人是访问不了你的网站的,
所以要想其他用户可以访问到你的项目就得改成
Allow from all加上一句下面的话
127.0.0.1 www.baidu.com–这个是你的域名,你要设置多少个虚拟主机,就要加多少行这样的记录。<Directory "E:\wamp\www\ecshop"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.localhost DocumentRoot E:\wamp\www\ecshop ServerName www.test.com ErrorLog logs/dummy-host2.localhost-error_log CustomLog logs/dummy-host2.localhost-access_log common </VirtualHost>
PHP Apache 配置虚拟主机,布布扣,bubuko.com
原文:http://blog.csdn.net/maildocgaojingru/article/details/24308179