设置虚拟主机Wamp

时间:2014-05-26 12:55:44

标签: php apache xampp wamp virtualhost

我知道这个问题已被问过好几次了,我甚至在我的公司做过很多次,但是,现在我想在家里设置一个虚拟主机并且它不起作用。

我做了什么:

Added xxx.localhost.de into the hosts

127.0.0.1 xxx.localhost.de

Uncommented include vhosts... in my httpd.conf

Include conf/extra/httpd-vhosts.conf

Set up a virtual host for my project

<VirtualHost *:80>
    ServerAdmin asdr@web.de
    DocumentRoot "D:\wamp\www\xxx"
    ServerName xxx.localhost.de
    ServerAlias xxx.localhost.de
    ErrorLog "logs/xxx-error.log"
    CustomLog "logs/xxx-access.log" common
</VirtualHost>

我没有收到错误 - wamp仍然正常启动,我可以使用正常路径访问它 localhost/... 但当我尝试通过xxx.localhost.de访问它时,我进入了网站&#34; www.localhost.de&#34;。它表现得像他不关心我的主机文件...

我究竟错过了什么?在我的公司里,它总是像这样工作。我已经检查了教程,它总是说这是所有需要的步骤。

谢谢!

3 个答案:

答案 0 :(得分:1)

我也有同样的问题,有几件事可以导致这种情况,首先尝试将DirectoryIndex index.php添加到

<VirtualHost *:80>
    ServerAdmin asdr@web.de
    DocumentRoot "D:\wamp\www\xxx"
    DirectoryIndex index.php
    ServerName xxx.localhost.de
    ServerAlias xxx.localhost.de
    ErrorLog "logs/xxx-error.log"
    CustomLog "logs/xxx-access.log" common
</VirtualHost>

然后你可以尝试在浏览器中写“http://you_address.local 如果这没有帮助,我会想到任何可能导致这种情况的事情

答案 1 :(得分:1)

试试这个: -

将HOSTS文件更改为: -

127.0.0.1 localhost
::1       localhost

127.0.0.1 project1.dev
::1       project1.dev

将Vhost定义为

<VirtualHost *:80>
    ServerAdmin asdr@web.de
    DocumentRoot "D:\wamp\www"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory  "D:/wamp/www">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin asdr@web.de
    DocumentRoot "D:\wamp\www\xxx"
    ServerName project1.dev
    ServerAlias www.project1.dev
    ErrorLog "logs/project1-error.log"
    CustomLog "logs/project1-access.log" common
    <Directory  "D:/wamp/www/xxx">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

答案 2 :(得分:0)

似乎我必须对hosts.ics文件进行更改,而不是对标准hosts文件进行更改。当时一切正常