Windows本地主机和虚拟主机上的Apache [英] Apache on Windows localhost and virtualhosts

查看:74
本文介绍了Windows本地主机和虚拟主机上的Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题,我在Windows 8.1机器上运行wamp 2.2.

So here is my problem, I'm running wamp 2.2 on a windows 8.1 machine.

现在,安装后,本地主机可以正常工作.当我创建虚拟主机时,设置httpd.conf文件后,例如,如果要创建:

Now, after the install, localhost works fine. When I go to create a virtual host, after setting up the httpd.conf file, if I were to create for example :

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

好吧,这只会覆盖我的本地主机.首先,test.local不起作用,如果我使用本地主机,它将带我到c:/wamp/www/test/

Well this just overrides my localhost. First of all, test.local does not work, and if I were to use localhost it takes me to c:/wamp/www/test/

有人对此有解决方案吗?

Anybody have a solution for this ?

PS:我一直在为Windows正确设置我的主机文件(addind:127.0.0.1 test.local),我的80端口是空闲的(未关闭skype和防病毒软件).

PS : I have been setting up my hosts file for windows correctly (addind: 127.0.0.1 test.local), and my 80 port is free (no skype and antivirus turned off).

我也尝试过使用其他端口(8080),问题仍然存在.

I've also tried with a different port (8080) and the problem continues.

我在浏览器中收到的消息是:"Google chrome无法找到该网站"

The message I get on my browser is : "Google chrome could not find the website"

推荐答案

如果设置了虚拟主机,但仍要访问localhost webroot,则需要先为localhost添加一个虚拟主机.>

If you have virtual hosts set up and you still want to access the localhost webroot, you need to add a vhost for your localhost first

主机消失

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

If you are adding virtual hosts to an existing web server, you must also create a block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

示例(未经测试):

NameVirtualHost *:80

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

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

这篇关于Windows本地主机和虚拟主机上的Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆