Php Windows本地主机和虚拟主机上的Apache

Php Windows本地主机和虚拟主机上的Apache,php,windows,apache,wamp,Php,Windows,Apache,Wamp,这就是我的问题,我在Windows8.1机器上运行WAMP2.2 现在,在安装之后,localhost工作正常。 在设置httpd.conf文件后,如果要创建虚拟主机,例如: <VirtualHost *:80> DocumentRoot "c:/wamp/www/test/" ServerName test.local </VirtualHost> DocumentRoot“c:/wamp/www/test/” ServerName test.local

这就是我的问题,我在Windows8.1机器上运行WAMP2.2

现在,在安装之后,localhost工作正常。 在设置httpd.conf文件后,如果要创建虚拟主机,例如:

<VirtualHost *:80>
   DocumentRoot "c:/wamp/www/test/"
   ServerName test.local
</VirtualHost>

DocumentRoot“c:/wamp/www/test/”
ServerName test.local
这会覆盖我的本地主机。首先,test.local不起作用,如果我使用localhost,它会将我带到c:/wamp/www/test/

有人能解决这个问题吗

PS:我已经正确设置了windows主机文件(addind:127.0.0.1 test.local),我的80端口是免费的(没有skype和防病毒软件关闭)

编辑:我还尝试了另一个端口(8080),问题仍然存在

我在浏览器上看到的信息是:“Google chrome找不到该网站”

试试这个:

<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test" 
ServerName  test.local
ServerAlias test.local
<directory "c:/wamp/www/test">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Require local
</directory>
</VirtualHost>

DocumentRoot“c:/wamp/www/test”
ServerName test.local
ServerAlias test.local
选项索引跟随符号链接
允许超越所有
命令拒绝,允许
要求本地

如果已设置虚拟主机,但仍要访问localhost webroot,则需要先为localhost添加vhost

主主机离开

如果要将虚拟主机添加到现有web服务器,还必须为现有主机创建块。此虚拟主机中包含的ServerName和DocumentRoot应与全局ServerName和DocumentRoot相同。首先在配置文件中列出此虚拟主机,使其充当默认主机

示例(未测试):

NameVirtualHost*:80
服务器名本地主机
DocumentRoot C:\wamp/www
ServerName otherdomain.local
DocumentRoot C:\wamp/www/otherdomain

嘿!谢谢你的帮助。现在我做到了,我得到了我一直得到的东西:Chrome(或其他浏览器)找不到页面。是的,那部分已经完成并工作了。Localhost运行正常,但第二个虚拟主机运行不正常。好吧,我不知道还能告诉你什么,因为我的示例直接来自文档。也许您可以发布当前的vhosts配置,包括
名称虚拟主机
本地主机
,以及您的测试域。您还可以浏览本页的常见错误配置:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot C:\wamp/www
</VirtualHost>

<VirtualHost *:80>
    ServerName otherdomain.local
    DocumentRoot C:\wamp/www/otherdomain
</VirtualHost>